Commit 4ddaaaef authored by Jake Oliversen's avatar Jake Oliversen

Added promises to async functions and corresponding jest tests.

parent e5098010
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){
console.log(err);
expect(err).toBeDefined();
}finally{
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) => {
console.log(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();
}
})
\ No newline at end of file
......@@ -18,4 +18,25 @@ test('Call getSling with leaveMangledNames option', done => {
})
})
test('Call getSling without callback', async done => {
try{
let data = await sc.getSling('test1', { leaveMangledNames: true });
expect(data['something']).toBe("here");
}catch(err){
expect(err).toBeDefined();
}finally{
done();
}
})
test('Call getSling without callback and options', async done => {
try{
let data = await sc.getSling('test1');
expect(data['something']).toBe("here");
}catch(err){
console.log("HERE");
expect(err).toBeDefined();
}finally{
done();
}
})
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