7729-devToTest_2430 #2739
|
@ -84,12 +84,13 @@ async function test() {
|
||||||
'loopback/**/*[sS]pec.js',
|
'loopback/**/*[sS]pec.js',
|
||||||
'modules/*/back/**/*.[sS]pec.js'
|
'modules/*/back/**/*.[sS]pec.js'
|
||||||
],
|
],
|
||||||
helpers: [`back/tests-helper.js`]
|
helpers: [`back/vn-jasmine.js`]
|
||||||
};
|
};
|
||||||
|
|
||||||
if (PARALLEL) {
|
if (PARALLEL) {
|
||||||
const ParallelRunner = require('jasmine/parallel');
|
const ParallelRunner = require('jasmine/parallel');
|
||||||
runner = new ParallelRunner({numWorkers: 1});
|
runner = new ParallelRunner({numWorkers: 1});
|
||||||
|
config.helpers.push(`back/tests-helper.js`);
|
||||||
} else {
|
} else {
|
||||||
const Jasmine = require('jasmine');
|
const Jasmine = require('jasmine');
|
||||||
runner = new Jasmine();
|
runner = new Jasmine();
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
|
||||||
|
const LoopBackContext = require('loopback-context');
|
||||||
|
const DEFAULT_ACCESS_TOKEN = {accessToken: {userId: 9}};
|
||||||
|
const DEFAULT_HEADERS = {headers: {origin: 'http://localhost'}};
|
||||||
|
const DEFAULT_BEFORE_ALL = {
|
||||||
|
ctx: {
|
||||||
|
req: {
|
||||||
|
...DEFAULT_ACCESS_TOKEN,
|
||||||
|
...DEFAULT_HEADERS
|
||||||
|
|
||||||
|
},
|
||||||
|
args: {}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const DEFAULT_LOOPBACK_CTX = {
|
||||||
|
...DEFAULT_ACCESS_TOKEN,
|
||||||
|
http: {
|
||||||
|
req: {
|
||||||
|
...DEFAULT_HEADERS
|
||||||
|
}
|
||||||
|
},
|
||||||
|
args: {}
|
||||||
|
};
|
||||||
|
|
||||||
|
function vnBeforeAll(value = DEFAULT_BEFORE_ALL) {
|
||||||
|
Object.assign(beforeAll, value);
|
||||||
|
}
|
||||||
|
function mockBeforeAll(value = DEFAULT_BEFORE_ALL) {
|
||||||
|
const origin = beforeAll.ctx;
|
||||||
|
Object.assign(origin, value);
|
||||||
|
return origin;
|
||||||
|
}
|
||||||
|
|
||||||
|
const mockLoopBackContext = (value = DEFAULT_LOOPBACK_CTX) => {
|
||||||
|
const activeCtx = value;
|
||||||
|
|
||||||
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||||
|
active: activeCtx
|
||||||
|
});
|
||||||
|
return activeCtx;
|
||||||
|
};
|
||||||
|
module.exports = {
|
||||||
|
mockBeforeAll, mockLoopBackContext
|
||||||
|
};
|
||||||
|
|
||||||
|
(function init() {
|
||||||
|
vnBeforeAll();
|
||||||
|
})();
|
Loading…
Reference in New Issue