UNPKG

semtest

Version:

NodeJs Unit test framework combining Tape, Proxyquire and Sinon

134 lines (131 loc) 4.8 kB
"use strict"; var _main = require("./main"); (0, _main.executeTests)("Test helpers library", [{ name: "executeTestsInternal", assertions: [{ when: "given a test engine, a module name, and an assertion block", should: "call the test engine accordingly", test: function (t) { t.plan(1); const tapeMock = () => t.pass(""); (0, _main.executeTestsInternal)(tapeMock)("", [{ assertions: ["foo"] }]); t.end(); } }, { when: "given a test engine, a module name, and an assertion block having an 'only' annoted assertion", should: "call the test engine accordingly", test: function (t) { t.plan(1); const tapeMock = { only: () => t.pass("") }; (0, _main.executeTestsInternal)(tapeMock)("", [{ assertions: [{ only: true }] }]); t.end(); } }, { when: "given a test engine, a module name, and an assertion block having a 'skip' annoted assertion", should: "call the test engine accordingly", test: function (t) { t.plan(1); const tapeMock = { skip: () => t.pass("") }; (0, _main.executeTestsInternal)(tapeMock)("", [{ assertions: [{ skip: true }] }]); t.end(); } }] }, { name: "idFn", assertions: [{ when: "given any input", should: "return the same value", test: t => _main.utilityFunctions.resolveFn(t.equal(_main.utilityFunctions.idFn("foo"), "foo")) }] }, { name: "idFnHO", assertions: [{ when: "given any input", should: "return the identity function", test: t => _main.utilityFunctions.resolveFn(t.equal(_main.utilityFunctions.idFnHO()("foo"), "foo")) }] }, { name: "nullFn", assertions: [{ when: "given any input", should: "return null", test: t => _main.utilityFunctions.resolveFn(t.equal(_main.utilityFunctions.nullFn(), null)) }] }, { name: "nullFnHO", assertions: [{ when: "given any input", should: "return a function that returns null", test: t => _main.utilityFunctions.resolveFn(t.equal(_main.utilityFunctions.nullFnHO()(), null)) }] }, { name: "thrownFn", assertions: [{ when: "given any input", should: "throw an error", test: t => _main.utilityFunctions.resolveFn(t.throws(_main.utilityFunctions.throwFn)) }] }, { name: "throwFnHO", assertions: [{ when: "given any input", should: "return a function that throws an error", test: t => _main.utilityFunctions.resolveFn(t.throws(_main.utilityFunctions.throwFnHO())) }] }, { name: "resolveFn", assertions: [{ when: "given any input", should: "return a resolved Promise", test: t => _main.utilityFunctions.resolveFn(_main.utilityFunctions.resolveFn().then(() => t.pass(""))) }] }, { name: "resolveFnHO", assertions: [{ when: "given any input", should: "return a function that returns a resolved Promise", test: t => _main.utilityFunctions.resolveFn(_main.utilityFunctions.resolveFnHO()().then(() => t.pass(""))) }] }, { name: "rejectFn", assertions: [{ when: "given any input", should: "return a rejected Promise", test: t => _main.utilityFunctions.resolveFn(_main.utilityFunctions.rejectFn().catch(() => t.pass(""))) }] }, { name: "rejectFnHO", assertions: [{ when: "its returned function is not given a rejection reason", should: "return a function that returns the base reason", test: t => _main.utilityFunctions.rejectFnHO("foo")().catch(rejection => t.equal(rejection.message, "foo")) }, { when: "its returned function is given a rejection reason", should: "return a function that returns the given reason", test: t => _main.utilityFunctions.rejectFnHO("foo")("bar").catch(rejection => t.equal(rejection.message, "bar")) }] }, { name: "createResponseMock", assertions: [{ should: "return an object that has a status method which alter the response status", test: t => _main.utilityFunctions.resolveFn(t.equal(_main.utilityFunctions.createResponseMock().status("foo").status, "foo")) }, { should: "return an object that has a json method which alter the response body", test: t => _main.utilityFunctions.resolveFn(t.equal(_main.utilityFunctions.createResponseMock().json("foo").body, "foo")) }] }]); //# sourceMappingURL=main.spec.js.map