X-Git-Url: http://git.squeep.com/?p=squeep-test-helper;a=blobdiff_plain;f=test%2Flib%2Fstub-database.js;fp=test%2Flib%2Fstub-database.js;h=883cc09dd308e60da165ae1fdf58e52e09f94246;hp=0000000000000000000000000000000000000000;hb=f4818ada492c17c8941616e935579ed7555ec636;hpb=3c28b4072422f3922ede43b91013e7da6d1e067e diff --git a/test/lib/stub-database.js b/test/lib/stub-database.js new file mode 100644 index 0000000..883cc09 --- /dev/null +++ b/test/lib/stub-database.js @@ -0,0 +1,44 @@ +/* eslint-env mocha */ +/* eslint-disable security/detect-object-injection */ +'use strict'; + +const assert = require('assert'); +const StubDatabase = require('../../lib/stub-database'); + +describe('StubDatabase', function () { + let db; + async function invokeAllImplementation() { + Promise.all(db._implementation.map(async (fn) => { + await db[fn](); + assert(db[fn].called, fn); + })); + } + + describe('Base', function () { + beforeEach(function () { + db = new StubDatabase(); + db._reset(); + }); + it('covers implementation', invokeAllImplementation); + }); // Base + + describe('Extended', function () { + class DB extends StubDatabase { + get _stubFns() { + return [ + ...super._stubFns, + 'valueGet', + 'valueSet', + ]; + } + async valueSet() { + return this; + } + } + beforeEach(function () { + db = new DB(); + db._reset(); + }); + it('covers implementation', invokeAllImplementation); + }); // Extended +}); // StubDatabase