Revert "feat: allow filter functions that return promises or the data directly"

This reverts commit e6c52cf26c.
This commit is contained in:
Barış Soner Uşaklı
2021-03-13 11:39:34 -05:00
parent e6c52cf26c
commit e725beaa4a
2 changed files with 32 additions and 34 deletions

View File

@@ -47,7 +47,7 @@ describe('Plugins', () => {
});
});
it('should register and fire a filter hook having 3 methods, one returning a promise, one calling the callback and one just returning', async () => {
it('should register and fire a filter hook having 2 methods, one returning a promise and the other calling the callback', (done) => {
function method1(data, callback) {
data.foo += 1;
callback(null, data);
@@ -58,17 +58,15 @@ describe('Plugins', () => {
resolve(data);
});
}
function method3(data) {
data.foo += 1;
return data;
}
plugins.hooks.register('test-plugin', { hook: 'filter:test.hook2', method: method1 });
plugins.hooks.register('test-plugin', { hook: 'filter:test.hook2', method: method2 });
plugins.hooks.register('test-plugin', { hook: 'filter:test.hook2', method: method3 });
const data = await plugins.hooks.fire('filter:test.hook2', { foo: 1 });
assert.strictEqual(data.foo, 8);
plugins.hooks.fire('filter:test.hook2', { foo: 1 }, (err, data) => {
assert.ifError(err);
assert.equal(data.foo, 7);
done();
});
});
it('should register and fire a filter hook that returns a promise that gets rejected', (done) => {