Skip to content

Commit a10cd34

Browse files
committed
Add GoodBye testing
1 parent 8c2c416 commit a10cd34

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

__tests__/GoodBye.spec.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React from 'react';
2+
import { shallow, mount } from 'enzyme';
3+
4+
import GoodBye from '../src';
5+
6+
describe('GoodBye', () => {
7+
test('should handleBeforeUnload handle function works expectedly', () => {
8+
const childFunction = jest.fn();
9+
const fakeMsg = "hello, world.";
10+
const evt = {};
11+
const wrapper = shallow(
12+
<GoodBye
13+
when
14+
alertBeforeUnload
15+
alertMessage={fakeMsg}
16+
children={childFunction}
17+
/>
18+
);
19+
expect(wrapper.instance().handleBeforeUnload(evt)).toBe(fakeMsg);
20+
expect(evt.returnValue).toBe(fakeMsg);
21+
});
22+
})

__tests__/provider.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { shallow } from 'enzyme';
3-
import GoodBye, { Provider, withGoodBye } from '../src';
3+
import { Provider } from '../src';
44

55
describe('<Provider />', () => {
66
test('should receive handleGetUserConfirm render prop', () => {

0 commit comments

Comments
 (0)