fix test
This commit is contained in:
parent
1be4f80fa3
commit
0e68972aba
1
.nyc_output/5ad64ed6-f8ad-4aa6-a4ce-4978c9a74881.json
Normal file
1
.nyc_output/5ad64ed6-f8ad-4aa6-a4ce-4978c9a74881.json
Normal file
File diff suppressed because one or more lines are too long
1
.nyc_output/9ed529ca-95a3-4f3d-a58a-4f5f1df16472.json
Normal file
1
.nyc_output/9ed529ca-95a3-4f3d-a58a-4f5f1df16472.json
Normal file
@ -0,0 +1 @@
|
||||
{}
|
@ -0,0 +1 @@
|
||||
{"parent":"9ed529ca-95a3-4f3d-a58a-4f5f1df16472","pid":16968,"argv":["/usr/bin/node","/home/timo/dev/requestor/node_modules/ava/lib/worker/subprocess.js"],"execArgv":[],"cwd":"/home/timo/dev/requestor","time":1582545546386,"ppid":16957,"coverageFilename":"/home/timo/dev/requestor/.nyc_output/5ad64ed6-f8ad-4aa6-a4ce-4978c9a74881.json","externalId":"","uuid":"5ad64ed6-f8ad-4aa6-a4ce-4978c9a74881","files":["/home/timo/dev/requestor/index.js","/home/timo/dev/requestor/test_files/root/all-root.js","/home/timo/dev/requestor/test_files/root/delete-root.js","/home/timo/dev/requestor/test_files/root/get-root.js","/home/timo/dev/requestor/test_files/root/not-root.js","/home/timo/dev/requestor/test_files/root/post-root.js","/home/timo/dev/requestor/test_files/root/put-root.js","/home/timo/dev/requestor/test_files/root.sub/all-root.sub.js","/home/timo/dev/requestor/test_files/root.sub/delete-root.sub.js","/home/timo/dev/requestor/test_files/root.sub/get-root.sub.js","/home/timo/dev/requestor/test_files/root.sub/not-root.sub.js","/home/timo/dev/requestor/test_files/root.sub/post-root.sub.js","/home/timo/dev/requestor/test_files/root.sub/put-root.sub.js","/home/timo/dev/requestor/test_files/sub/all-sub.js","/home/timo/dev/requestor/test_files/sub/all-sub.root.js","/home/timo/dev/requestor/test_files/sub/delete-sub.js","/home/timo/dev/requestor/test_files/sub/get-sub.js","/home/timo/dev/requestor/test_files/sub/get-sub.lv1.lv2.lv3.js","/home/timo/dev/requestor/test_files/sub/not-sub.js","/home/timo/dev/requestor/test_files/sub/post-sub.js","/home/timo/dev/requestor/test_files/sub/put-sub.js"]}
|
@ -0,0 +1 @@
|
||||
{"parent":null,"pid":16957,"argv":["/usr/bin/node","/home/timo/dev/requestor/node_modules/.bin/ava"],"execArgv":[],"cwd":"/home/timo/dev/requestor","time":1582545545515,"ppid":16946,"coverageFilename":"/home/timo/dev/requestor/.nyc_output/9ed529ca-95a3-4f3d-a58a-4f5f1df16472.json","externalId":"","uuid":"9ed529ca-95a3-4f3d-a58a-4f5f1df16472","files":[]}
|
1
.nyc_output/processinfo/index.json
Normal file
1
.nyc_output/processinfo/index.json
Normal file
@ -0,0 +1 @@
|
||||
{"processes":{"5ad64ed6-f8ad-4aa6-a4ce-4978c9a74881":{"parent":"9ed529ca-95a3-4f3d-a58a-4f5f1df16472","children":[]},"9ed529ca-95a3-4f3d-a58a-4f5f1df16472":{"parent":null,"children":["5ad64ed6-f8ad-4aa6-a4ce-4978c9a74881"]}},"files":{"/home/timo/dev/requestor/index.js":["5ad64ed6-f8ad-4aa6-a4ce-4978c9a74881"],"/home/timo/dev/requestor/test_files/root/all-root.js":["5ad64ed6-f8ad-4aa6-a4ce-4978c9a74881"],"/home/timo/dev/requestor/test_files/root/delete-root.js":["5ad64ed6-f8ad-4aa6-a4ce-4978c9a74881"],"/home/timo/dev/requestor/test_files/root/get-root.js":["5ad64ed6-f8ad-4aa6-a4ce-4978c9a74881"],"/home/timo/dev/requestor/test_files/root/not-root.js":["5ad64ed6-f8ad-4aa6-a4ce-4978c9a74881"],"/home/timo/dev/requestor/test_files/root/post-root.js":["5ad64ed6-f8ad-4aa6-a4ce-4978c9a74881"],"/home/timo/dev/requestor/test_files/root/put-root.js":["5ad64ed6-f8ad-4aa6-a4ce-4978c9a74881"],"/home/timo/dev/requestor/test_files/root.sub/all-root.sub.js":["5ad64ed6-f8ad-4aa6-a4ce-4978c9a74881"],"/home/timo/dev/requestor/test_files/root.sub/delete-root.sub.js":["5ad64ed6-f8ad-4aa6-a4ce-4978c9a74881"],"/home/timo/dev/requestor/test_files/root.sub/get-root.sub.js":["5ad64ed6-f8ad-4aa6-a4ce-4978c9a74881"],"/home/timo/dev/requestor/test_files/root.sub/not-root.sub.js":["5ad64ed6-f8ad-4aa6-a4ce-4978c9a74881"],"/home/timo/dev/requestor/test_files/root.sub/post-root.sub.js":["5ad64ed6-f8ad-4aa6-a4ce-4978c9a74881"],"/home/timo/dev/requestor/test_files/root.sub/put-root.sub.js":["5ad64ed6-f8ad-4aa6-a4ce-4978c9a74881"],"/home/timo/dev/requestor/test_files/sub/all-sub.js":["5ad64ed6-f8ad-4aa6-a4ce-4978c9a74881"],"/home/timo/dev/requestor/test_files/sub/all-sub.root.js":["5ad64ed6-f8ad-4aa6-a4ce-4978c9a74881"],"/home/timo/dev/requestor/test_files/sub/delete-sub.js":["5ad64ed6-f8ad-4aa6-a4ce-4978c9a74881"],"/home/timo/dev/requestor/test_files/sub/get-sub.js":["5ad64ed6-f8ad-4aa6-a4ce-4978c9a74881"],"/home/timo/dev/requestor/test_files/sub/get-sub.lv1.lv2.lv3.js":["5ad64ed6-f8ad-4aa6-a4ce-4978c9a74881"],"/home/timo/dev/requestor/test_files/sub/not-sub.js":["5ad64ed6-f8ad-4aa6-a4ce-4978c9a74881"],"/home/timo/dev/requestor/test_files/sub/post-sub.js":["5ad64ed6-f8ad-4aa6-a4ce-4978c9a74881"],"/home/timo/dev/requestor/test_files/sub/put-sub.js":["5ad64ed6-f8ad-4aa6-a4ce-4978c9a74881"]},"externalIds":{}}
|
@ -4,7 +4,7 @@
|
||||
"description": "Split express paths into individual files to make api programming more structured",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "mocha",
|
||||
"test": "nyc ava",
|
||||
"lint": "eslint .",
|
||||
"ci": "yarn --frozen-lockfile && node jenkins.js"
|
||||
},
|
||||
@ -22,6 +22,8 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@scode/eslint-config": "^1.2.15",
|
||||
"eslint": "^6.8.0"
|
||||
"ava": "^3.4.0",
|
||||
"eslint": "^6.8.0",
|
||||
"nyc": "^15.0.0"
|
||||
}
|
||||
}
|
||||
|
54
test/main.js
54
test/main.js
@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const { test } = require ('ava');
|
||||
const test = require ('ava');
|
||||
|
||||
const requestor = require ('../index');
|
||||
|
||||
@ -23,61 +23,61 @@ const mock = {
|
||||
}
|
||||
};
|
||||
|
||||
test.test.beforeEach (() => {
|
||||
mock.registered = {};
|
||||
});
|
||||
|
||||
test ('detect requests on root', (t) => {
|
||||
requestor (mock, '/test/root');
|
||||
mock.registered = {};
|
||||
requestor (mock, './test_files/root');
|
||||
const keys = [
|
||||
'post-/',
|
||||
'get-/',
|
||||
'put-/',
|
||||
'all-/',
|
||||
'delete-/',
|
||||
'all-/'
|
||||
'get-/',
|
||||
'post-/',
|
||||
'put-/'
|
||||
];
|
||||
|
||||
t.deepEqual (Object.keys (mock.registered), keys);
|
||||
});
|
||||
|
||||
test ('detect requests on root.subfolder', (t) => {
|
||||
requestor (mock, './test/root.sub');
|
||||
mock.registered = {};
|
||||
requestor (mock, './test_files/root.sub');
|
||||
const keys = [
|
||||
'post-/sub/',
|
||||
'get-/sub/',
|
||||
'put-/sub/',
|
||||
'all-/sub/',
|
||||
'delete-/sub/',
|
||||
'all-/sub/'
|
||||
'get-/sub/',
|
||||
'post-/sub/',
|
||||
'put-/sub/'
|
||||
];
|
||||
|
||||
t.deepEqual (Object.keys (mock.registered), keys);
|
||||
});
|
||||
|
||||
test ('detect requests on subfolder', (t) => {
|
||||
requestor (mock, './test/sub');
|
||||
mock.registered = {};
|
||||
requestor (mock, './test_files/sub');
|
||||
const keys = [
|
||||
'post-/sub/',
|
||||
'get-/sub/',
|
||||
'put-/sub/',
|
||||
'delete-/sub/',
|
||||
'all-/sub/',
|
||||
'all-/sub/root/',
|
||||
'delete-/sub/',
|
||||
'get-/sub/',
|
||||
'get-/sub/lv1/lv2/lv3/',
|
||||
'all-/sub/root/'
|
||||
'post-/sub/',
|
||||
'put-/sub/'
|
||||
];
|
||||
|
||||
t.deepEqual (Object.keys (mock.registered), keys);
|
||||
});
|
||||
|
||||
test ('build requests with subdirectory', (t) => {
|
||||
requestor (mock, './test/sub', { subdir: 'test' });
|
||||
mock.registered = {};
|
||||
requestor (mock, './test_files/sub', { subdir: 'test' });
|
||||
const keys = [
|
||||
'post-/test/sub/',
|
||||
'get-/test/sub/',
|
||||
'put-/test/sub/',
|
||||
'delete-/test/sub/',
|
||||
'all-/test/sub/',
|
||||
'all-/test/sub/root/',
|
||||
'delete-/test/sub/',
|
||||
'get-/test/sub/',
|
||||
'get-/test/sub/lv1/lv2/lv3/',
|
||||
'all-/test/sub/root/'
|
||||
'post-/test/sub/',
|
||||
'put-/test/sub/'
|
||||
];
|
||||
|
||||
t.deepEqual (Object.keys (mock.registered), keys);
|
||||
|
Reference in New Issue
Block a user