Skip to content

Commit

Permalink
fix up earwurm test
Browse files Browse the repository at this point in the history
  • Loading branch information
beefchimi committed Dec 22, 2023
1 parent bebec8c commit 89e70fa
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/tests/Earwurm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ describe('Earwurm component', () => {
expect(spyKeysChange).toBeCalledWith(mockInitialKeys, []);
expect(spyKeysChange).toBeCalledTimes(1);

// Does not add/remove when both `id + path` are identical.
mockManager.add(mockEntries[0]);
expect(spyKeysChange).not.toBeCalledTimes(2);

Expand All @@ -279,6 +280,19 @@ describe('Earwurm component', () => {
[...mockInitialKeys, mockUniqueEntry.id],
mockInitialKeys,
);

const keysSnapshot = mockManager.keys;

// Emits twice as an existing key is removed then re-added
// as a result of the `path` value changing.
mockManager.add({...mockUniqueEntry, path: 'changed'});
expect(spyKeysChange).toBeCalledTimes(4);

expect(spyKeysChange).toBeCalledWith(mockInitialKeys, keysSnapshot);
expect(spyKeysChange).toHaveBeenLastCalledWith(
keysSnapshot,
mockInitialKeys,
);
});

// TODO: Figure out how best to read `fadeMs` and `request` from Stack.
Expand Down

0 comments on commit 89e70fa

Please sign in to comment.