initial commit
[squeep-test-helper] / test / lib / stub-database.js
1 /* eslint-env mocha */
2 /* eslint-disable security/detect-object-injection */
3 'use strict';
4
5 const assert = require('assert');
6 const StubDatabase = require('../../lib/stub-database');
7
8 describe('StubDatabase', function () {
9 let db;
10 async function invokeAllImplementation() {
11 Promise.all(db._implementation.map(async (fn) => {
12 await db[fn]();
13 assert(db[fn].called, fn);
14 }));
15 }
16
17 describe('Base', function () {
18 beforeEach(function () {
19 db = new StubDatabase();
20 db._reset();
21 });
22 it('covers implementation', invokeAllImplementation);
23 }); // Base
24
25 describe('Extended', function () {
26 class DB extends StubDatabase {
27 get _stubFns() {
28 return [
29 ...super._stubFns,
30 'valueGet',
31 'valueSet',
32 ];
33 }
34 async valueSet() {
35 return this;
36 }
37 }
38 beforeEach(function () {
39 db = new DB();
40 db._reset();
41 });
42 it('covers implementation', invokeAllImplementation);
43 }); // Extended
44 }); // StubDatabase