Commit 8c167658 authored by Jake Oliversen's avatar Jake Oliversen

Merge branch 'issue/2-promisifying-async-functions' of...

Merge branch 'issue/2-promisifying-async-functions' of gitlab.entropy.cc:blacklight/npm-sling-connector into issue/2-promisifying-async-functions
parents 241b240b 70a03f68
This diff is collapsed.
{
"res": {
"statusCode": 200,
"headers": "some headers"
},
"data": {
"something": "here",
"jcr:something": "also here",
"another": {
"deeper": "one"
}
}
}
\ No newline at end of file
const SlingConnector = require('../sling-connector');
const sc = new SlingConnector({baseUri: "../__fixtures__"});
test('Call get with callback', done => {
sc.get('test1' , (err, data) => {
expect(data['something']).toBe('here');
done();
})
})
test('Call get without callback', async done => {
try{
let data = await sc.get('test1');
expect(data['something']).toBe("here");
}catch(err){
expect(err).toBeDefined();
}finally{
done();
}
})
\ No newline at end of file
const request = require("request");
const SlingConnector = require('../sling-connector');
const _ = require("lodash");
const sc = new SlingConnector({baseUri: "../__fixtures__"});
beforeEach(() => {
request.mockClear();
});
describe("get-if-exists", ()=> {
test("not applied to standard JSON call", (done) => {
sc.getRaw("/content/raw/simple.1.json", (err, data) => {
expect(err).toBeFalsy();
expect(data).toBeTruthy();
expect(typeof data).toBe('string');
done();
});
});
});
\ No newline at end of file
const SlingConnector = require('../sling-connector');
const sc = new SlingConnector({baseUri: "../__fixtures__"});
test('Call getRaw with callback', done => {
sc.getRaw('test1' , (err, data) => {
expect(data).toBe("{\"something\":\"here\",\"_jcr_something\":\"also here\",\"another\":{\"deeper\":\"one\"}}");
done();
})
})
test('Call get without callback', async done => {
try{
let data = await sc.getRaw('test1');
expect(data).toBe("{\"something\":\"here\",\"_jcr_something\":\"also here\",\"another\":{\"deeper\":\"one\"}}");
}catch(err){
expect(err).toBeDefined();
}finally{
done();
}
})
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment