Skip to content

Commit f08f132

Browse files
committed
test: "cleanup" function
1 parent 45ca61c commit f08f132

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/__tests__/cleanup.test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// @flow
2+
/* eslint-disable react/no-multi-comp */
3+
import React from 'react';
4+
import { View } from 'react-native';
5+
import { cleanup, render } from '..';
6+
7+
class Test extends React.Component<*> {
8+
componentWillUnmount() {
9+
if (this.props.onUnmount) {
10+
this.props.onUnmount();
11+
}
12+
}
13+
render() {
14+
return <View />;
15+
}
16+
}
17+
18+
test('cleanup', () => {
19+
const fn = jest.fn();
20+
render(<Test onUnmount={fn} />);
21+
expect(fn).not.toHaveBeenCalled();
22+
cleanup();
23+
expect(fn).toHaveBeenCalled();
24+
});

0 commit comments

Comments
 (0)