killing mutants

This commit is contained in:
2020-03-26 13:31:07 +01:00
parent 03f0104bca
commit c1fcde7d6f
23 changed files with 79 additions and 71 deletions

View File

@ -30,7 +30,7 @@ const mock = {
}
};
test ('detect requests on root', (t) => {
test ('detect requests on root', async (t) => {
mock.registered = {};
requestor (mock, './test_files/root');
const keys = [
@ -42,9 +42,14 @@ test ('detect requests on root', (t) => {
];
t.deepEqual (Object.keys (mock.registered), keys);
const res = await Promise.all (
Object.values (mock.registered)
.map ((val) => val ())
);
t.is (res.filter ((val) => val === 'dummy').length, keys.length);
});
test ('detect requests on root.subfolder', (t) => {
test ('detect requests on root.subfolder', async (t) => {
mock.registered = {};
requestor (mock, './test_files/root.sub');
const keys = [
@ -56,9 +61,14 @@ test ('detect requests on root.subfolder', (t) => {
];
t.deepEqual (Object.keys (mock.registered), keys);
const res = await Promise.all (
Object.values (mock.registered)
.map ((val) => val ())
);
t.is (res.filter ((val) => val === 'dummy').length, keys.length);
});
test ('detect requests on subfolder', (t) => {
test ('detect requests on subfolder', async (t) => {
mock.registered = {};
requestor (mock, './test_files/sub');
const keys = [
@ -72,9 +82,14 @@ test ('detect requests on subfolder', (t) => {
];
t.deepEqual (Object.keys (mock.registered), keys);
const res = await Promise.all (
Object.values (mock.registered)
.map ((val) => val ())
);
t.is (res.filter ((val) => val === 'dummy').length, keys.length);
});
test ('build requests with subdirectory', (t) => {
test ('build requests with subdirectory', async (t) => {
mock.registered = {};
requestor (mock, './test_files/sub', { subdir: 'test' });
const keys = [
@ -88,4 +103,25 @@ test ('build requests with subdirectory', (t) => {
];
t.deepEqual (Object.keys (mock.registered), keys);
const res = await Promise.all (
Object.values (mock.registered)
.map ((val) => val ())
);
t.is (res.filter ((val) => val === 'dummy').length, keys.length);
});
test ('should rethrow', async (t) => {
mock.registered = {};
requestor (mock, './test_files/throw');
const [ func ] = Object.values (mock.registered);
await t.throwsAsync (func);
});
test ('should not rethrow', async (t) => {
mock.registered = {};
requestor (mock, './test_files/throw', { rethrow: false });
const [ func ] = Object.values (mock.registered);
await t.notThrowsAsync (func);
});