Commit f6ee9e8e authored by Caleb Weeks's avatar Caleb Weeks

adding simple test around getRaw

parent 78dba12c
module.exports = require('./simple.json');
\ No newline at end of file
module.exports = {
"res": {
"statusCode": 200,
"headers": "some headers"
},
"data": {
"key": "value",
"something": "here",
"jcr:something": "also here",
"another": {
"deeper": "one"
}
}
}
\ No newline at end of file
......@@ -4,6 +4,16 @@ module.exports = jest.fn(function (reqOptions, reqCallback) {
let uriParts = testUri.split('/');
let fixturesIndex = uriParts.indexOf('__fixtures__');
uriParts.splice(fixturesIndex + 1, 0, 'request');
const test = require(uriParts.join('/'));
let test;
try{
test = require(uriParts.join('/'));
} catch (e){
test = {
err: `Failed to require ${uriParts.join('/')} ` + e.message,
statusCode: 500
}
}
reqCallback(test.err ? test.err : null, test.res, JSON.stringify(test.data));
})
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
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