diff --git a/.vscode/launch.json b/.vscode/launch.json index 353f088..0f197ac 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,7 +10,10 @@ "name": "test unit", "program": "${workspaceFolder}/tests/unit/", "outputCapture": "std", - "protocol": "inspector" + "protocol": "inspector", + "args": [ + "--coverage-report=text" + ] } ] } \ No newline at end of file diff --git a/package.json b/package.json index 8e7cb95..0673698 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ }, "devDependencies": { "tap": "^15.0.9", - "semantic-release": "^17.4.3" + "semantic-release": "^17.4.4" }, "scripts": { "unit-test": "./node_modules/tap/bin/run.js --no-cov ./tests/unit/base/" diff --git a/tests/unit/all/1.js b/tests/unit/all/1.js deleted file mode 100644 index b1319a4..0000000 --- a/tests/unit/all/1.js +++ /dev/null @@ -1,50 +0,0 @@ -const {basename} = require('path'); - -module.exports = async({A, B}) => { - /* method not found */ - try { - let inR = await A.pass({ - packet: { - payload: 3, - meta: {method: 'a.b'} - }, - direction: 'in' - }); - await inR.promise; - } catch (e) { - console.error(e); - } - - try { - let prev = await A.pass({ - packet: { - payload: 3, - meta: {method: 'b'} - }, - direction: 'in' - }); - - setTimeout(async() => { - try { - let sec = await B.pass({ - packet: { - payload: 3, - meta: { - method: 'b', - idx: prev.idx - } - }, - direction: 'in' - }); - await sec.promise; - } catch (e) { - console.error(e); - } - }, 1); - await prev.promise; - } catch (e) { - console.error(e); - } - return console.info(basename(__filename)); - -}; \ No newline at end of file diff --git a/tests/unit/all/echo.js b/tests/unit/all/echo.js deleted file mode 100644 index c35db88..0000000 --- a/tests/unit/all/echo.js +++ /dev/null @@ -1,3 +0,0 @@ -require('net') - .createServer((socket) => socket.pipe(socket)) - .listen(9090); \ No newline at end of file diff --git a/tests/unit/all/inboundDirectFullFill.js b/tests/unit/all/inboundDirectFullFill.js deleted file mode 100644 index 1ee3926..0000000 --- a/tests/unit/all/inboundDirectFullFill.js +++ /dev/null @@ -1,14 +0,0 @@ -const {basename} = require('path'); - -module.exports = async({A}) => { - let inR = await A.pass({ - packet: { - payload: 3, - meta: {method: 'a.b'} - }, - direction: 'in' - }); - setTimeout(A.requests.fulfill(inR), 100); - await inR.promise; - return console.info(basename(__filename)); -}; \ No newline at end of file diff --git a/tests/unit/all/inboundFullFillThroughOutbound.js b/tests/unit/all/inboundFullFillThroughOutbound.js deleted file mode 100644 index 9d99ba5..0000000 --- a/tests/unit/all/inboundFullFillThroughOutbound.js +++ /dev/null @@ -1,31 +0,0 @@ -const {basename} = require('path'); - -module.exports = async({A}) => { - try { - let inR = await A.pass({ - packet: { - payload: 3, - meta: {method: 'a.b'} - }, - direction: 'in' - }); - setTimeout(async() => { - let outR = await A.pass({ - packet: { - payload: 3, - meta: {idx: inR.idx, nodeId: inR.nodeId} - }, - direction: 'out' - }); - try { - await outR.promise; - } catch (e) { - console.error(e); - } - }, 100); - await inR.promise; - } catch (e) { - console.error(e); - } - return console.info(basename(__filename)); -}; \ No newline at end of file diff --git a/tests/unit/all/init/1.js b/tests/unit/all/init/1.js deleted file mode 100644 index cba654d..0000000 --- a/tests/unit/all/init/1.js +++ /dev/null @@ -1,26 +0,0 @@ -const {base} = require('../../../../index'); - -module.exports = async() => { - const A = new base(); - - A.method.add({ - method: 'a.b.in', - fn: ({payload}) => payload + 1 - }); - A.method.add({ - method: 'a.b.out', - fn: ({payload}) => payload + 43 - }); - - const B = new base(); - B.method.add({ - method: 'b.in', - fn: ({payload}) => payload + 1 - }); - B.method.add({ - method: 'b.out', - fn: ({payload}) => payload + 43 - }); - - return () => ({A, B}); -}; \ No newline at end of file diff --git a/tests/unit/all/init/2.js b/tests/unit/all/init/2.js deleted file mode 100644 index 9b359ce..0000000 --- a/tests/unit/all/init/2.js +++ /dev/null @@ -1,35 +0,0 @@ -const {base} = require('../../../../index'); - -module.exports = async() => { - const A = new base({config: {request: {waitTime: 5000000}}}); - - A.method.add({ - method: 'a.b.in', - fn: ({payload}) => payload + 1 - }); - A.method.add({ - method: 'a.b.out', - fn: ({payload}) => payload + 43 - }); - A.method.add({ - method: 'b.in', - fn: ({payload}) => payload + 1 - }); - A.method.add({ - method: 'b.out', - fn: ({payload}) => payload + 43 - }); - - const B = new base({config: {request: {waitTime: 2000}}}); - B.method.add({ - method: 'b.in', - fn: ({payload}) => payload + 1 - }); - B.method.add({ - method: 'b.out', - fn: ({payload}) => payload + 43 - }); - await A.start({other: B}); - await B.start({other: A}); - return () => ({A, B}); -}; \ No newline at end of file diff --git a/tests/unit/all/outboundDirectFullFill.js b/tests/unit/all/outboundDirectFullFill.js deleted file mode 100644 index 09ed8b9..0000000 --- a/tests/unit/all/outboundDirectFullFill.js +++ /dev/null @@ -1,14 +0,0 @@ -const {basename} = require('path'); - -module.exports = async({A}) => { - let outR = await A.pass({ - packet: { - payload: 3, - meta: {method: 'a.b'} - }, - direction: 'out' - }); - setTimeout(A.requests.fulfill(outR), 100); - await outR.promise; - return console.info(basename(__filename)); -}; \ No newline at end of file diff --git a/tests/unit/all/outboundFullFillThroughInbound.js b/tests/unit/all/outboundFullFillThroughInbound.js deleted file mode 100644 index 3b6415c..0000000 --- a/tests/unit/all/outboundFullFillThroughInbound.js +++ /dev/null @@ -1,31 +0,0 @@ -const {basename} = require('path'); - -module.exports = async({A}) => { - try { - let outR = await A.pass({ - packet: { - payload: 3, - meta: {method: 'a.b'} - }, - direction: 'out' - }); - setTimeout(async() => { - try { - let inR = await A.pass({ - packet: { - payload: 3, - meta: {idx: outR.idx, nodeId: outR.nodeId} - }, - direction: 'in' - }); - await inR.promise; - } catch (e) { - console.error(e); - } - }, 100); - await outR.promise; - } catch (e) { - console.error(e); - } - return console.info(basename(__filename)); -}; \ No newline at end of file diff --git a/tests/unit/all/test.index.js b/tests/unit/all/test.index.js deleted file mode 100644 index 8351ca7..0000000 --- a/tests/unit/all/test.index.js +++ /dev/null @@ -1,22 +0,0 @@ -require('./echo'); -const init1 = require('./init/1'); -const init2 = require('./init/2'); -const inboundDirectFullFill = require('./inboundDirectFullFill'); -const outboundDirectFullFill = require('./outboundDirectFullFill'); -const inboundFullFillThroughOutbound = require('./inboundFullFillThroughOutbound'); -const outboundFullFillThroughInbound = require('./outboundFullFillThroughInbound'); -const a1 = require('./1'); - -(async() => { - const {A: A1} = (await init1())(); - const {A: A2, B: B2} = (await init2())(); - - await inboundDirectFullFill({A: A1}); - await outboundDirectFullFill({A: A1}); - await inboundFullFillThroughOutbound({A: A1}); - await outboundFullFillThroughInbound({A: A1}); - await a1({A: A2, B: B2}); - - console.log('finished'); -})(); -