Skip to content

Commit

Permalink
Add test for step runner composition
Browse files Browse the repository at this point in the history
  • Loading branch information
ghengeveld committed Aug 10, 2022
1 parent 501b7e1 commit 118fe17
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions code/lib/store/src/csf/composeConfigs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
});
});

0 comments on commit 118fe17

Please sign in to comment.