-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
546 additions
and
13 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import 'react-native' | ||
import React from 'react' | ||
import { shallow } from 'enzyme' | ||
import renderer from 'react-test-renderer' | ||
import Enzyme from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
import OrientationHOC from '../../src/components/OrientationHOC' | ||
|
||
Enzyme.configure({ adapter: new Adapter() }); | ||
|
||
describe('OrientationHOC', () => { | ||
let ElementToBeWrapped = 'TestElement' | ||
let Component; | ||
const orientation = 'PORTRAIT' | ||
|
||
beforeEach(() => { | ||
Component = OrientationHOC(ElementToBeWrapped) | ||
}) | ||
|
||
it('is function', () => { | ||
expect(OrientationHOC).toBeInstanceOf(Function) | ||
}) | ||
|
||
it('renders correctly', () => { | ||
const tree = renderer.create(<Component />).toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}) | ||
|
||
it('initial state', () => { | ||
const component = shallow(<Component />) | ||
expect(component.state()).toEqual({ orientation }); | ||
}) | ||
|
||
it('handleLayoutChange should set state', () => { | ||
const component = shallow(<Component />) | ||
component.setState({ orientation: 'LANDSCAPE' }) | ||
component.instance().handleLayoutChange() | ||
expect(component.state('orientation')).toEqual(orientation); | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`OrientationHOC renders correctly 1`] = ` | ||
<View | ||
onLayout={[Function]} | ||
style={ | ||
Object { | ||
"flex": 1, | ||
} | ||
} | ||
> | ||
<TestElement | ||
orientation="PORTRAIT" | ||
/> | ||
</View> | ||
`; |
Oops, something went wrong.