Skip to content

Commit

Permalink
cast container type because of an type issue currently in testing-lib…
Browse files Browse the repository at this point in the history
  • Loading branch information
pabra committed Dec 13, 2020
1 parent 8978974 commit ff06c88
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions __tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -291,14 +291,18 @@ test('avoid unnecessary re-rendering', async () => {
};

const timeout = 500;
const { container, getByTestId } = render(
const { container: containerElement, getByTestId } = render(
<div>
<ClickView recurseCount={3} />
<ClickButtonAdd />
<ClickButtonReset />
</div>,
);

// https://github.com/testing-library/react-testing-library/issues/841
// https://github.com/testing-library/dom-testing-library/pull/834
const container: HTMLElement = containerElement as HTMLElement;

// each element's renderer and effect should have been called once
expect(getByTestId('render-clicks-3').textContent).toBe('clicks: 0');
expect(getByTestId('render-clicks-2').textContent).toBe('clicks: 0');
Expand Down Expand Up @@ -447,14 +451,18 @@ test('avoid unnecessary re-rendering with just setters and state consumers', asy
};

const timeout = 500;
const { container, getByTestId } = render(
const { container: containerElement, getByTestId } = render(
<div>
<ClickView recurseCount={3} />
<ClickButtonAdd />
<ClickButtonReset />
</div>,
);

// https://github.com/testing-library/react-testing-library/issues/841
// https://github.com/testing-library/dom-testing-library/pull/834
const container: HTMLElement = containerElement as HTMLElement;

// each element's renderer and effect should have been called once
expect(getByTestId('render-clicks-3').textContent).toBe('clicks: 0');
expect(getByTestId('render-clicks-2').textContent).toBe('clicks: 0');
Expand Down Expand Up @@ -611,7 +619,7 @@ test('update same state multiple times', async () => {
};

const timeout = 500;
const { container, getByTestId } = render(
const { container: containerElement, getByTestId } = render(
<div>
<View id={1} />
<IncA />
Expand All @@ -621,6 +629,10 @@ test('update same state multiple times', async () => {
</div>,
);

// https://github.com/testing-library/react-testing-library/issues/841
// https://github.com/testing-library/dom-testing-library/pull/834
const container: HTMLElement = containerElement as HTMLElement;

expect(getByTestId('inc-c').textContent).toBe('inc 10');
expect(getByTestId('view-1').textContent).toBe('a: 1, b: 6, c: 11');
expect(getByTestId('view-2').textContent).toBe('a: 1, b: 6, c: 11');
Expand Down

0 comments on commit ff06c88

Please sign in to comment.