Skip to content

Commit

Permalink
Improve based on feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamBergamin committed Nov 5, 2024
1 parent 864f00e commit d615212
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions test/unit/CustomFunction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,33 +30,26 @@ describe('CustomFunction', () => {
const fn = new CustomFunction('test_callback_id', MOCK_MIDDLEWARE_MULTIPLE, { autoAcknowledge: true });
assert.isNotNull(fn);
});

it('should accept a variety of options', async () => {
const fn = new CustomFunction('test_callback_id', MOCK_MIDDLEWARE_MULTIPLE, { autoAcknowledge: false });
assert.isNotNull(fn);
});
});

describe('getListeners', () => {
it('should return a properly ordered array of listeners', async () => {
it('should return an ordered array of listeners used to map function events to handlers', async () => {
const cbId = 'test_executed_callback_id';
const fn = new CustomFunction(cbId, MOCK_MIDDLEWARE_SINGLE, { autoAcknowledge: true });
const listeners = fn.getListeners();
assert.equal(listeners.length, 5);
assert.equal(listeners[0], onlyEvents);
assert.equal(listeners[1].toString(), matchEventType('function_executed').toString());
assert.equal(listeners[2].toString(), matchCallbackId(cbId).toString());
assert.equal(listeners[3], autoAcknowledge);
assert.equal(listeners[4], MOCK_FN);
});

it('should return a properly ordered array of listeners when auto acknowledge is disabled', async () => {
it('should return a array of listeners without the autoAcknowledge middleware when auto acknowledge is disabled', async () => {
const cbId = 'test_executed_callback_id';
const fn = new CustomFunction(cbId, MOCK_MIDDLEWARE_SINGLE, { autoAcknowledge: false });
const listeners = fn.getListeners();
assert.equal(listeners[0], onlyEvents);
assert.equal(listeners[1].toString(), matchEventType('function_executed').toString());
assert.equal(listeners[2].toString(), matchCallbackId(cbId).toString());
assert.equal(listeners[3], MOCK_FN);
assert.isFalse(listeners.includes(autoAcknowledge));
});
});

Expand Down

0 comments on commit d615212

Please sign in to comment.