7729-devToTest_2430 #2739

Merged
alexm merged 339 commits from 7729-devToTest_2430 into test 2024-07-16 07:11:37 +00:00
2 changed files with 50 additions and 1 deletions
Showing only changes of commit d6ee5d571e - Show all commits

View File

@ -84,12 +84,13 @@ async function test() {
'loopback/**/*[sS]pec.js',
'modules/*/back/**/*.[sS]pec.js'
],
helpers: [`back/tests-helper.js`]
helpers: [`back/vn-jasmine.js`]
};
if (PARALLEL) {
const ParallelRunner = require('jasmine/parallel');
runner = new ParallelRunner({numWorkers: 1});
config.helpers.push(`back/tests-helper.js`);
} else {
const Jasmine = require('jasmine');
runner = new Jasmine();

48
back/vn-jasmine.js Normal file
View File

@ -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();
})();