Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should successfully return v4 and no error', done => {
// Freezes time so date created within function will be Feb 8, 2016
const clock = lolex.install(1454962445000);
const res = headerAuthCheck(request, log);
clock.uninstall();
assert.strictEqual(res.err, null);
assert.strictEqual(res.params.version, 4);
done();
});
});
beforeEach(function () {
this.axios = new AxiosMockAdapter(axios);
this.localVue = createLocalVue();
this.store = createStore(this.localVue);
container.bind(STORE_ID).toConstantValue(this.store);
this.router = createRouter(this.localVue);
container.bind(ROUTER_ID).toConstantValue(this.router);
// mocking setTimeout, clearTimeout global function and enable time traveling
let globalMock = {};
this.clock = lolex.install({ target: globalMock, toFake: ['setTimeout', 'clearTimeout'] });
container.rebind(GLOBAL_ID).toConstantValue(globalMock);
this.mountLoginView = function (options) {
let wrapper = mount(LoginView, { localVue: this.localVue, router: this.router, store: this.store, ...options });
return new LoginViewPageObj(wrapper);
};
this.router.push({ name: 'login' });
return flushPromises();
});
beforeEach(async () => {
clock = lolex.install()
Promise = BluebirdPromise
Promise.setScheduler((fn) => fn())
})
beforeAll(() => {
clock = lolex.install({ now: 12345678000 });
broker = new ServiceBroker({
logger: false,
nodeID: "node-123",
metrics: {
reporter: {
type: "Event",
options: {
eventName: "$metrics.custom",
interval: 0,
onlyChanges: true,
broadcast: true,
excludes: ["moleculer.node.versions.moleculer"]
}
}
}
beforeEach(() => {
win = env.win;
doc = win.document;
clock = lolex.install({
target: window,
now: new Date('2018-01-01T08:00:00Z'),
});
});
return createIframePromise().then(iframe => {
win = iframe.win;
clock = lolex.install({target: win});
});
});
function stubTimers () {
const timers = new Timers()
const clock = installClock(timers, 0, ['clearInterval', 'setInterval', 'clearTimeout', 'setTimeout'])
return { clock, timers }
}
if (expressions[i]) {
const result = Object.create(expressions[i])
result.value = value
result.isException = false
result.when = Date.now()
results.push(result);
}
return value
}
const ctx = sandbox()
ctx[nameOfSpy] = spy
const clock = lolex.install({
target: ctx,
now: Date.now(),
toFake: [
'setTimeout', 'clearTimeout',
'setInterval', 'clearInterval',
'setImmediate', 'clearImmediate',
'Date'
],
loopLimit: 100
})
const instrumented = generate(ast)
try {
const script = new vm.Script(instrumented, {filename: 'inspect-code'})
script.runInContext(vm.createContext(ctx))