Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RoyEJohnson committed May 23, 2024
1 parent 55a52bf commit f0e562b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/app/content/components/Topbar/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ const dispatchSearchShortcut = (target: HTMLElement | undefined) => {
);
const tb = node.querySelector<HTMLElement>('[class*="TopBar"]');

expect(document?.activeElement?.tagName).toBe('INPUT');
act(() => dispatchSearchShortcut(tb!));
act(() => dispatchSearchShortcut(tb!));
expect(document?.activeElement?.tagName).toBe('MAIN');
});

it('goes to search results when provided', () => {
Expand All @@ -124,7 +125,9 @@ const dispatchSearchShortcut = (target: HTMLElement | undefined) => {
store.dispatch(receiveSearchResults(makeSearchResults()));

act(() => dispatchSearchShortcut(tb!));
expect(document?.activeElement?.tagName).toBe('INPUT');
act(() => dispatchSearchShortcut(tb!));
expect(document?.activeElement?.classList.contains('SearchResultsBar')).toBe(true);
});

it('aborts on mobile', () => {
Expand All @@ -142,10 +145,11 @@ const dispatchSearchShortcut = (target: HTMLElement | undefined) => {
const tb = node.querySelector<HTMLElement>('[class*="TopBar"]');

act(() => dispatchSearchShortcut(tb!));
expect(document?.activeElement?.tagName).toBe('INPUT');
act(() => dispatchSearchShortcut(tb!));
expect(document?.activeElement?.tagName).not.toBe('MAIN');
});


it('doesn\'t dispatch search for empty string', () => {
const component = render();
const findById = makeFindByTestId(component.root);
Expand Down

0 comments on commit f0e562b

Please sign in to comment.