linting
This commit is contained in:
parent
cf9e238dc7
commit
9b85bb119f
@ -12,6 +12,6 @@ module.exports = {
|
||||
node: true
|
||||
},
|
||||
extends: [
|
||||
'@scode/eslint-config-ts'
|
||||
'@scode'
|
||||
]
|
||||
}
|
||||
|
@ -5,6 +5,13 @@
|
||||
* Created by Timo Hocker <timo@scode.ovh>, March 2020
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = () => 'dummy';
|
||||
module.exports = {
|
||||
env: {
|
||||
commonjs: true,
|
||||
es6: true,
|
||||
node: true
|
||||
},
|
||||
extends: [
|
||||
'@scode/eslint-config-ts'
|
||||
]
|
||||
}
|
@ -25,7 +25,6 @@
|
||||
"@scode/eslint-config-ts": "^1.0.1",
|
||||
"@stryker-mutator/core": "^3.1.0",
|
||||
"@stryker-mutator/javascript-mutator": "^3.1.0",
|
||||
"ava": "^3.5.2",
|
||||
"eslint": "^6.8.0",
|
||||
"nyc": "^15.0.0"
|
||||
},
|
||||
|
127
test/main.js
127
test/main.js
@ -1,127 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Sapphirecode - All Rights Reserved
|
||||
* This file is part of Requestor which is released under BSD-3-Clause.
|
||||
* See file 'LICENSE' for full license details.
|
||||
* Created by Timo Hocker <timo@scode.ovh>, March 2020
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const test = require ('ava');
|
||||
|
||||
const requestor = require ('../index');
|
||||
|
||||
const mock = {
|
||||
registered: {},
|
||||
post (path, handler) {
|
||||
this.registered[`post-${path}`] = handler;
|
||||
},
|
||||
get (path, handler) {
|
||||
this.registered[`get-${path}`] = handler;
|
||||
},
|
||||
put (path, handler) {
|
||||
this.registered[`put-${path}`] = handler;
|
||||
},
|
||||
delete (path, handler) {
|
||||
this.registered[`delete-${path}`] = handler;
|
||||
},
|
||||
all (path, handler) {
|
||||
this.registered[`all-${path}`] = handler;
|
||||
}
|
||||
};
|
||||
|
||||
test ('detect requests on root', async (t) => {
|
||||
mock.registered = {};
|
||||
requestor (mock, './test_files/root');
|
||||
const keys = [
|
||||
'all-/',
|
||||
'delete-/',
|
||||
'get-/',
|
||||
'post-/',
|
||||
'put-/'
|
||||
];
|
||||
|
||||
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', async (t) => {
|
||||
mock.registered = {};
|
||||
requestor (mock, './test_files/root.sub');
|
||||
const keys = [
|
||||
'all-/sub/',
|
||||
'delete-/sub/',
|
||||
'get-/sub/',
|
||||
'post-/sub/',
|
||||
'put-/sub/'
|
||||
];
|
||||
|
||||
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', async (t) => {
|
||||
mock.registered = {};
|
||||
requestor (mock, './test_files/sub');
|
||||
const keys = [
|
||||
'all-/sub/',
|
||||
'all-/sub/root/',
|
||||
'delete-/sub/',
|
||||
'get-/sub/',
|
||||
'get-/sub/lv1/lv2/lv3/',
|
||||
'post-/sub/',
|
||||
'put-/sub/'
|
||||
];
|
||||
|
||||
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', async (t) => {
|
||||
mock.registered = {};
|
||||
requestor (mock, './test_files/sub', { subdir: 'test' });
|
||||
const keys = [
|
||||
'all-/test/sub/',
|
||||
'all-/test/sub/root/',
|
||||
'delete-/test/sub/',
|
||||
'get-/test/sub/',
|
||||
'get-/test/sub/lv1/lv2/lv3/',
|
||||
'post-/test/sub/',
|
||||
'put-/test/sub/'
|
||||
];
|
||||
|
||||
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);
|
||||
});
|
@ -1,10 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Sapphirecode - All Rights Reserved
|
||||
* This file is part of Requestor which is released under BSD-3-Clause.
|
||||
* See file 'LICENSE' for full license details.
|
||||
* Created by Timo Hocker <timo@scode.ovh>, March 2020
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = () => 'dummy';
|
@ -1,10 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Sapphirecode - All Rights Reserved
|
||||
* This file is part of Requestor which is released under BSD-3-Clause.
|
||||
* See file 'LICENSE' for full license details.
|
||||
* Created by Timo Hocker <timo@scode.ovh>, March 2020
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = () => 'dummy';
|
@ -1,10 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Sapphirecode - All Rights Reserved
|
||||
* This file is part of Requestor which is released under BSD-3-Clause.
|
||||
* See file 'LICENSE' for full license details.
|
||||
* Created by Timo Hocker <timo@scode.ovh>, March 2020
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = () => 'dummy';
|
@ -1,10 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Sapphirecode - All Rights Reserved
|
||||
* This file is part of Requestor which is released under BSD-3-Clause.
|
||||
* See file 'LICENSE' for full license details.
|
||||
* Created by Timo Hocker <timo@scode.ovh>, March 2020
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = () => 'dummy';
|
@ -1,10 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Sapphirecode - All Rights Reserved
|
||||
* This file is part of Requestor which is released under BSD-3-Clause.
|
||||
* See file 'LICENSE' for full license details.
|
||||
* Created by Timo Hocker <timo@scode.ovh>, March 2020
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = () => 'dummy';
|
@ -1,10 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Sapphirecode - All Rights Reserved
|
||||
* This file is part of Requestor which is released under BSD-3-Clause.
|
||||
* See file 'LICENSE' for full license details.
|
||||
* Created by Timo Hocker <timo@scode.ovh>, March 2020
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = () => 'dummy';
|
@ -1,10 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Sapphirecode - All Rights Reserved
|
||||
* This file is part of Requestor which is released under BSD-3-Clause.
|
||||
* See file 'LICENSE' for full license details.
|
||||
* Created by Timo Hocker <timo@scode.ovh>, March 2020
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = () => 'dummy';
|
@ -1,10 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Sapphirecode - All Rights Reserved
|
||||
* This file is part of Requestor which is released under BSD-3-Clause.
|
||||
* See file 'LICENSE' for full license details.
|
||||
* Created by Timo Hocker <timo@scode.ovh>, March 2020
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = () => 'dummy';
|
@ -1,10 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Sapphirecode - All Rights Reserved
|
||||
* This file is part of Requestor which is released under BSD-3-Clause.
|
||||
* See file 'LICENSE' for full license details.
|
||||
* Created by Timo Hocker <timo@scode.ovh>, March 2020
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = () => 'dummy';
|
@ -1,10 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Sapphirecode - All Rights Reserved
|
||||
* This file is part of Requestor which is released under BSD-3-Clause.
|
||||
* See file 'LICENSE' for full license details.
|
||||
* Created by Timo Hocker <timo@scode.ovh>, March 2020
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = () => 'dummy';
|
@ -1,10 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Sapphirecode - All Rights Reserved
|
||||
* This file is part of Requestor which is released under BSD-3-Clause.
|
||||
* See file 'LICENSE' for full license details.
|
||||
* Created by Timo Hocker <timo@scode.ovh>, March 2020
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = () => 'dummy';
|
@ -1,10 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Sapphirecode - All Rights Reserved
|
||||
* This file is part of Requestor which is released under BSD-3-Clause.
|
||||
* See file 'LICENSE' for full license details.
|
||||
* Created by Timo Hocker <timo@scode.ovh>, March 2020
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = () => 'dummy';
|
@ -1,10 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Sapphirecode - All Rights Reserved
|
||||
* This file is part of Requestor which is released under BSD-3-Clause.
|
||||
* See file 'LICENSE' for full license details.
|
||||
* Created by Timo Hocker <timo@scode.ovh>, March 2020
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = () => 'dummy';
|
@ -1,10 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Sapphirecode - All Rights Reserved
|
||||
* This file is part of Requestor which is released under BSD-3-Clause.
|
||||
* See file 'LICENSE' for full license details.
|
||||
* Created by Timo Hocker <timo@scode.ovh>, March 2020
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = () => 'dummy';
|
@ -1,10 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Sapphirecode - All Rights Reserved
|
||||
* This file is part of Requestor which is released under BSD-3-Clause.
|
||||
* See file 'LICENSE' for full license details.
|
||||
* Created by Timo Hocker <timo@scode.ovh>, March 2020
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = () => 'dummy';
|
@ -1,10 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Sapphirecode - All Rights Reserved
|
||||
* This file is part of Requestor which is released under BSD-3-Clause.
|
||||
* See file 'LICENSE' for full license details.
|
||||
* Created by Timo Hocker <timo@scode.ovh>, March 2020
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = () => 'dummy';
|
@ -1,10 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Sapphirecode - All Rights Reserved
|
||||
* This file is part of Requestor which is released under BSD-3-Clause.
|
||||
* See file 'LICENSE' for full license details.
|
||||
* Created by Timo Hocker <timo@scode.ovh>, March 2020
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = () => 'dummy';
|
@ -1,10 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Sapphirecode - All Rights Reserved
|
||||
* This file is part of Requestor which is released under BSD-3-Clause.
|
||||
* See file 'LICENSE' for full license details.
|
||||
* Created by Timo Hocker <timo@scode.ovh>, March 2020
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = () => 'dummy';
|
@ -1,10 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Sapphirecode - All Rights Reserved
|
||||
* This file is part of Requestor which is released under BSD-3-Clause.
|
||||
* See file 'LICENSE' for full license details.
|
||||
* Created by Timo Hocker <timo@scode.ovh>, March 2020
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = () => 'dummy';
|
@ -1,12 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) Sapphirecode - All Rights Reserved
|
||||
* This file is part of Requestor which is released under BSD-3-Clause.
|
||||
* See file 'LICENSE' for full license details.
|
||||
* Created by Timo Hocker <timo@scode.ovh>, March 2020
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
module.exports = () => {
|
||||
throw new Error ('foo');
|
||||
};
|
Reference in New Issue
Block a user