feat: remove sync hooks support

v1.18.x
Barış Soner Uşaklı 4 years ago
parent 4e490f6058
commit 01956af43a

@ -137,10 +137,6 @@ async function fireFilterHook(hook, hookList, params) {
payload => resolve(payload), payload => resolve(payload),
err => reject(err) err => reject(err)
); );
return;
}
if (returned) {
resolve(returned);
} }
}); });
} }

@ -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, one calling the callback', async () => {
function method1(data, callback) { function method1(data, callback) {
data.foo += 1; data.foo += 1;
callback(null, data); callback(null, data);
@ -58,14 +58,9 @@ describe('Plugins', () => {
resolve(data); 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: method1 });
plugins.hooks.register('test-plugin', { hook: 'filter:test.hook2', method: method2 }); 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 }); const data = await plugins.hooks.fire('filter:test.hook2', { foo: 1 });
assert.strictEqual(data.foo, 8); assert.strictEqual(data.foo, 8);

Loading…
Cancel
Save