Skip to content

Commit

Permalink
test(lazycomponent): use async act
Browse files Browse the repository at this point in the history
test against div's text content

fix #7
  • Loading branch information
aneurysmjs committed Aug 11, 2019
1 parent ec09ef8 commit 3d9fcba
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/app/components/shared/LazyComponent/LazyComponent.test.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
// @flow strict
import React from 'react';
import { act } from 'react-dom/test-utils';
// $FlowFixMe
import { render } from '@testing-library/react';

import LazyComponent from './LazyComponent';

const Example = () => <div> Some Component </div>;
const Example = () => <div>Some Component</div>;

describe('LazyComponent', () => {
it('should have component\'s name as className', () => {
const { container } = render(
<LazyComponent getModule={() => Promise.resolve({ default: Example })} />,
);
it('should have component\'s name as className', async () => {
let testRenderer = {};

await act(async () => {
testRenderer = render(
<LazyComponent getModule={() => Promise.resolve({ default: Example })} />,
);
});
const { container } = testRenderer;
const div = container.firstChild;
expect(div).toEqual(null);

expect(div.textContent).toEqual('Some Component');
});
});

0 comments on commit 3d9fcba

Please sign in to comment.