Skip to content

Commit 355c396

Browse files
committed
Add test cases for withGoodBye HoC
1 parent 96f9d94 commit 355c396

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

__tests__/provider.spec.js

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

55
describe('<Provider />', () => {

__tests__/withGoodBye.spec.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from 'react';
2+
import { withGoodBye } from '../src';
3+
import { shallow } from 'enzyme';
4+
5+
describe('withGoodBye', () => {
6+
const BaseComponent = () => <div />;
7+
const EnhancedComponent = withGoodBye(BaseComponent);
8+
9+
test('should have correct displayName', () => {
10+
expect(EnhancedComponent.displayName).toBe(`withGoodBye(${BaseComponent.name})`);
11+
})
12+
13+
test('should receive own props from EnhancedComponent to BaseComponent', () => {
14+
const myProps = { foo: 1, bar: 2 };
15+
const wrapper = shallow(<EnhancedComponent {...myProps}/>);
16+
expect(wrapper.dive().find(BaseComponent).props().foo).toEqual(1);
17+
expect(wrapper.dive().find(BaseComponent).props().bar).toEqual(2);
18+
})
19+
20+
test('should receive getUserConfirmation prop function', () => {
21+
const wrapper = shallow(<EnhancedComponent />);
22+
expect(wrapper.dive().find(BaseComponent).props().getUserConfirmation).toBeDefined();
23+
})
24+
25+
});

0 commit comments

Comments
 (0)