Skip to content

Commit

Permalink
fix: naming
Browse files Browse the repository at this point in the history
  • Loading branch information
zetxx committed Jul 26, 2021
1 parent 572d215 commit 714f1a7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion tests/unit/bridge/test.bridge.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const tap = require('tap');
const method = require('../../../lib/bridge')();
const bridge = require('../../../lib/bridge')();

tap.test('Bridge', (t) => {
t.end();
Expand Down
26 changes: 13 additions & 13 deletions tests/unit/methods/test.methods.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
const tap = require('tap');
const method = require('../../../lib/methods')();
const methods = require('../../../lib/methods')();
const {NotFound} = require('../../../lib/methods/errors');

tap.test('Method', (t) => {
t.type(method, 'object', 'method Is object');
t.type(method.add, 'function', 'method.add is function');
t.type(method.find, 'function', 'method.find is function');
t.type(method.call, 'function', 'method.call is function');
method.add({method: 'abc.in', fn: () => 1});
t.type(methods, 'object', 'method Is object');
t.type(methods.add, 'function', 'method.add is function');
t.type(methods.find, 'function', 'method.find is function');
t.type(methods.call, 'function', 'method.call is function');
methods.add({method: 'abc.in', fn: () => 1});

t.throws(
() => method.find(),
() => methods.find(),
new NotFound('method: undefined not found'),
'should throw'
);

t.throws(
() => method.find({direction: 'in', packet: {meta: {method: 'abcd'}}}),
() => methods.find({direction: 'in', packet: {meta: {method: 'abcd'}}}),
new NotFound('method: abcd not found'),
'should throw'
);

t.rejects(
method.call({direction: 'in', packet: {meta: {method: 'abcd'}}}),
methods.call({direction: 'in', packet: {meta: {method: 'abcd'}}}),
new NotFound('method: abcd not found'),
'should throw'
);
t.throws(
() => method.find({direction: 'in', packet: {meta: {method: 'abcd'}}}),
() => methods.find({direction: 'in', packet: {meta: {method: 'abcd'}}}),
new NotFound('method: abcd not found'),
'should throw'
);

t.type(
method.find({direction: 'in', packet: {meta: {method: 'abc'}}}),
methods.find({direction: 'in', packet: {meta: {method: 'abc'}}}),
'function',
'method.find should returns function'
);

t.resolves(
method.call({direction: 'in', packet: {meta: {method: 'abc'}}}),
methods.call({direction: 'in', packet: {meta: {method: 'abc'}}}),
'should resolves'
);

t.resolveMatch(
method.call({direction: 'in', packet: {meta: {method: 'abc'}}}),
methods.call({direction: 'in', packet: {meta: {method: 'abc'}}}),
1,
'should resolves to value'
);
Expand Down

0 comments on commit 714f1a7

Please sign in to comment.