Add test for step runner composition

This commit is contained in:
Gert Hengeveld 2022-08-10 12:10:47 +02:00
parent 501b7e1b25
commit 118fe17652

View File

@ -157,4 +157,22 @@ describe('composeConfigs', () => {
runStep: expect.any(Function),
});
});
it('composes step runners', () => {
const fn = jest.fn();
const { runStep } = composeConfigs([
{ runStep: (label, play, context) => fn(`${label}1`, play(context)) },
{ runStep: (label, play, context) => fn(`${label}2`, play(context)) },
{ runStep: (label, play, context) => fn(`${label}3`, play(context)) },
]);
// @ts-expect-error We don't care about the context value here
runStep('Label', () => {}, {});
expect(fn).toHaveBeenCalledTimes(3);
expect(fn).toHaveBeenNthCalledWith(1, 'Label3', expect.anything());
expect(fn).toHaveBeenNthCalledWith(2, 'Label2', expect.anything());
expect(fn).toHaveBeenNthCalledWith(3, 'Label1', expect.anything());
});
});