feat: bring back static hook timeout

This commit is contained in:
Barış Soner Uşaklı
2021-03-11 22:56:14 -05:00
parent 56b0bfd518
commit 46270f9f20
2 changed files with 35 additions and 4 deletions

View File

@@ -135,6 +135,21 @@ describe('Plugins', () => {
});
});
it('should register and timeout a static hook returning a promise but takes too long', (done) => {
async function method(data) {
assert.equal(data.bar, 'test');
return new Promise((resolve) => {
setTimeout(resolve, 6000);
});
}
plugins.hooks.register('test-plugin', { hook: 'static:test.hook', method: method });
plugins.hooks.fire('static:test.hook', { bar: 'test' }, (err) => {
assert.ifError(err);
plugins.hooks.unregister('test-plugin', 'static:test.hook', method);
done();
});
});
it('should get plugin data from nbbpm', (done) => {
plugins.get('nodebb-plugin-markdown', (err, data) => {
assert.ifError(err);