Skip to content

Commit 51ac9c4

Browse files
committed
chore: update tests
1 parent cfd6f9c commit 51ac9c4

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

__tests__/useViewport.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { renderHook, act } from '@testing-library/react-hooks';
22

33
import { useViewport } from '../src';
44

5+
// TODO
56
declare global {
67
namespace NodeJS {
78
interface Global {

__tests__/withViewport.test.tsx

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,35 @@ import { withViewport } from '../src';
55

66
import { Sizes } from '../src/interfaces/sizes';
77

8-
const renderResult = ({ vw, vh }: Sizes) => (
9-
<>
10-
<p data-testid="vw">{vw}</p>
11-
<p data-testid="vh">{vh}</p>
12-
</>
13-
);
8+
const checkResult = ({ vw, vh }: Sizes) => {
9+
expect(vw).toBe(1024);
10+
expect(vh).toBe(768);
11+
12+
return null;
13+
};
1414

1515
describe('withViewport usage with functional component', () => {
1616
const FunctionalComponent = (props: Sizes) => {
17-
return renderResult(props);
17+
return checkResult(props);
1818
};
1919

2020
const FunctionalComponentHOC = withViewport()(FunctionalComponent);
2121

2222
it('should render vw and wh values', () => {
23-
const { getByTestId } = render(<FunctionalComponentHOC />);
24-
25-
expect(getByTestId('vw').innerHTML).toBe('1024');
26-
expect(getByTestId('vh').innerHTML).toBe('768');
23+
render(<FunctionalComponentHOC />);
2724
});
2825
});
2926

3027
describe('withViewport usage with class component', () => {
3128
class ClassComponent extends Component<Sizes> {
3229
render() {
33-
return renderResult(this.props);
30+
return checkResult(this.props);
3431
}
3532
}
3633

3734
const ClassComponentHOC = withViewport()(ClassComponent);
3835

3936
it('should render vw and wh values', () => {
40-
const { getByTestId } = render(<ClassComponentHOC />);
41-
42-
expect(getByTestId('vw').innerHTML).toBe('1024');
43-
expect(getByTestId('vh').innerHTML).toBe('768');
37+
render(<ClassComponentHOC />);
4438
});
4539
});

0 commit comments

Comments
 (0)