Skip to content

Commit

Permalink
fix crossword component tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tblackwell-tm committed Mar 8, 2024
1 parent 788e686 commit 2e511dd
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/components/Crossword/Crossword.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import validData from './../../testData/test.valid.1';
import { act, fireEvent, render, screen } from './../../utils/rtl';
import Crossword from './Crossword';

const debounceTime = 1000;
const DEBOUNCE_TIME = 1000;

test('it renders', () => {
render(
<Crossword
allowedHtmlTags={DEFAULT_HTML_TAGS}
allowMissingSolutions={false}
cellMatcher={DEFAULT_CELL_MATCHER}
data={validData}
id="test"
Expand Down Expand Up @@ -41,6 +42,7 @@ test('it displays error with invalid data', () => {
render(
<Crossword
allowedHtmlTags={DEFAULT_HTML_TAGS}
allowMissingSolutions={false}
cellMatcher={DEFAULT_CELL_MATCHER}
data={invalidData}
id="test"
Expand Down Expand Up @@ -74,6 +76,7 @@ test('it displays valid guess grid', () => {
render(
<Crossword
allowedHtmlTags={DEFAULT_HTML_TAGS}
allowMissingSolutions={false}
cellMatcher={DEFAULT_CELL_MATCHER}
data={validData}
id="test"
Expand All @@ -89,6 +92,7 @@ test('it displays error with invalid guess grid', () => {
render(
<Crossword
allowedHtmlTags={DEFAULT_HTML_TAGS}
allowMissingSolutions={false}
cellMatcher={DEFAULT_CELL_MATCHER}
data={validData}
id="test"
Expand All @@ -109,6 +113,7 @@ test.skip('it calls saveGrid', () => {
render(
<Crossword
allowedHtmlTags={DEFAULT_HTML_TAGS}
allowMissingSolutions={false}
cellMatcher={DEFAULT_CELL_MATCHER}
data={validData}
id="test"
Expand All @@ -126,7 +131,7 @@ test.skip('it calls saveGrid', () => {
fireEvent.keyDown(grid, { key: 'A', code: 'KeyA' });

act(() => {
jest.advanceTimersByTime(debounceTime);
jest.advanceTimersByTime(DEBOUNCE_TIME);
});
expect(saveGrid).toHaveBeenCalledTimes(2);

Expand All @@ -142,6 +147,7 @@ test('it always shows sticky clue', async () => {
render(
<Crossword
allowedHtmlTags={DEFAULT_HTML_TAGS}
allowMissingSolutions={false}
cellMatcher={DEFAULT_CELL_MATCHER}
data={validData}
id="test"
Expand All @@ -162,6 +168,7 @@ test('it never shows sticky clue', async () => {
render(
<Crossword
allowedHtmlTags={DEFAULT_HTML_TAGS}
allowMissingSolutions={false}
cellMatcher={DEFAULT_CELL_MATCHER}
data={validData}
id="test"
Expand All @@ -183,6 +190,7 @@ test('it conditionally shows sticky clue', async () => {
const { rerender } = render(
<Crossword
allowedHtmlTags={DEFAULT_HTML_TAGS}
allowMissingSolutions={false}
cellMatcher={DEFAULT_CELL_MATCHER}
data={validData}
id="test"
Expand All @@ -202,6 +210,7 @@ test('it conditionally shows sticky clue', async () => {
rerender(
<Crossword
allowedHtmlTags={DEFAULT_HTML_TAGS}
allowMissingSolutions={false}
cellMatcher={DEFAULT_CELL_MATCHER}
data={validData}
id="test"
Expand Down

0 comments on commit 2e511dd

Please sign in to comment.