bump package version to 1.2.3
[squeep-authentication-module] / test / stub-db.js
1 /* eslint-disable security/detect-object-injection */
2 'use strict';
3
4 const sinon = require('sinon'); // eslint-disable-line node/no-unpublished-require
5
6 const spyFns = [
7 'context',
8 'transaction',
9 ];
10
11 const stubFns = [
12 'authenticationSuccess',
13 'authenticationGet',
14 'authenticationUpsert',
15 ];
16
17 const stubDatabase = {
18 _implementation: [ ...spyFns, ...stubFns ],
19 _reset: () => {
20 spyFns.forEach((fn) => sinon.spy(stubDatabase, fn));
21 stubFns.forEach((fn) => sinon.stub(stubDatabase, fn));
22 },
23 context: async (fn) => await fn({}),
24 transaction: async (dbCtx, fn) => await fn(dbCtx),
25 };
26
27 stubFns.forEach((fn) => {
28 stubDatabase[fn] = () => {};
29 });
30
31 module.exports = stubDatabase;