Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Elin Angelow committed Jan 12, 2024
1 parent c437717 commit 56db779
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tests/unit/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
require('./test.methods-1');
require('./test.methods-wires');
require('./test.methods-wires');
18 changes: 17 additions & 1 deletion tests/unit/test.methods-wires.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,17 @@ methods2.add({name: 'a.b.fn.notify', fn: async(m, {notify}) => await notify({met
methods3.add({name: 'a.b.fn3', fn: (m) => 123});
methods3.add({name: 'a.b.fn2.throws', fn: (m) => {throw new Error('abc')}});
methods4.add({name: 'a.b.fn2.resolve.after.timeout', fn: (m) => {
return new Promise((resolve, reject) => {
return new Promise((resolve) => {
setTimeout(() => {resolve(123);}, 1000);
});
}});
methods4.add({name: 'a.b.fn2.reject.after.timeout', fn: async(m) => {
return await (new Promise((reject) => {
setTimeout(() => {
reject(new Error('123'));
}, 2000);
}));
}});
tap.test('Wires + Methods', async(t) => {
try {
await methods1.ask({id: 1, method: 'a1', params: [123]});
Expand Down Expand Up @@ -99,6 +106,15 @@ tap.test('Wires + Methods', async(t) => {
'resolve after request times out'
);
}
try {
r = await methods1.ask({method: 'a.b.fn2.reject.after.timeout', meta: {timeout: 500}, params: [123]});
} catch ({error}) {
t.same(
error.message,
'TimeOut',
'rejects after request times out'
);
}
t.end();
});

0 comments on commit 56db779

Please sign in to comment.