-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: add snapshots for mocked and unmocked components (#24554)
Summary: Per a conversation with TheSavior, in #24538, this adds snapshot tests for all components whose mocks will be addressed in that PR. Shallow and deep snapshots are included. [General] [Added] - Snapshots Pull Request resolved: #24554 Differential Revision: D15062197 Pulled By: cpojer fbshipit-source-id: 70ddbaa5e6d1d2c0fd1130ab04c458d9c49d0ee8
- Loading branch information
1 parent
ec90ad1
commit de12b98
Showing
12 changed files
with
528 additions
and
7 deletions.
There are no files selected for viewing
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
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
66 changes: 66 additions & 0 deletions
66
Libraries/Components/DatePicker/__tests__/DatePickerIOS-test.js
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,66 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
* @emails oncall+react_native | ||
* @flow | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const React = require('React'); | ||
const DatePickerIOS = require('DatePickerIOS'); | ||
const render = require('../../../../jest/renderer'); | ||
|
||
describe('DatePickerIOS', () => { | ||
it('should render as <View> when mocked', () => { | ||
const instance = render.create( | ||
<DatePickerIOS | ||
date={new Date(1555883690956)} | ||
mode="date" | ||
onDateChange={jest.fn()} | ||
/>, | ||
); | ||
expect(instance).toMatchSnapshot(); | ||
}); | ||
|
||
it('should shallow render as <DatePickerIOS> when mocked', () => { | ||
const output = render.shallow( | ||
<DatePickerIOS | ||
date={new Date(1555883690956)} | ||
mode="date" | ||
onDateChange={jest.fn()} | ||
/>, | ||
); | ||
expect(output).toMatchSnapshot(); | ||
}); | ||
|
||
it('should shallow render as <DatePickerIOS> when not mocked', () => { | ||
jest.dontMock('DatePickerIOS'); | ||
|
||
const output = render.shallow( | ||
<DatePickerIOS | ||
date={new Date(1555883690956)} | ||
mode="date" | ||
onDateChange={jest.fn()} | ||
/>, | ||
); | ||
expect(output).toMatchSnapshot(); | ||
}); | ||
|
||
it('should render as <View> when not mocked', () => { | ||
jest.dontMock('DatePickerIOS'); | ||
|
||
const instance = render.create( | ||
<DatePickerIOS | ||
date={new Date(1555883690956)} | ||
mode="date" | ||
onDateChange={jest.fn()} | ||
/>, | ||
); | ||
expect(instance).toMatchSnapshot(); | ||
}); | ||
}); |
51 changes: 51 additions & 0 deletions
51
Libraries/Components/DatePicker/__tests__/__snapshots__/DatePickerIOS-test.js.snap
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,51 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`DatePickerIOS should render as <View> when mocked 1`] = ` | ||
<View> | ||
<RCTDatePicker | ||
date={1555883690956} | ||
mode="date" | ||
onChange={[Function]} | ||
onResponderTerminationRequest={[Function]} | ||
onStartShouldSetResponder={[Function]} | ||
style={ | ||
Object { | ||
"height": 216, | ||
} | ||
} | ||
/> | ||
</View> | ||
`; | ||
exports[`DatePickerIOS should render as <View> when not mocked 1`] = ` | ||
<View> | ||
<RCTDatePicker | ||
date={1555883690956} | ||
mode="date" | ||
onChange={[Function]} | ||
onResponderTerminationRequest={[Function]} | ||
onStartShouldSetResponder={[Function]} | ||
style={ | ||
Object { | ||
"height": 216, | ||
} | ||
} | ||
/> | ||
</View> | ||
`; | ||
exports[`DatePickerIOS should shallow render as <DatePickerIOS> when mocked 1`] = ` | ||
<DatePickerIOS | ||
date={2019-04-21T21:54:50.956Z} | ||
mode="date" | ||
onDateChange={[MockFunction]} | ||
/> | ||
`; | ||
exports[`DatePickerIOS should shallow render as <DatePickerIOS> when not mocked 1`] = ` | ||
<DatePickerIOS | ||
date={2019-04-21T21:54:50.956Z} | ||
mode="date" | ||
onDateChange={[MockFunction]} | ||
/> | ||
`; |
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
69 changes: 69 additions & 0 deletions
69
Libraries/Components/DrawerAndroid/__tests__/DrawerAndroid-test.js
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,69 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
* @emails oncall+react_native | ||
* @flow | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const React = require('React'); | ||
// $FlowFixMe | ||
const DrawerLayoutAndroid = require('../DrawerLayoutAndroid.android'); | ||
const View = require('View'); | ||
|
||
const render = require('../../../../jest/renderer'); | ||
|
||
describe('<DrawerLayoutAndroid />', () => { | ||
it('should render as <DrawerLayoutAndroid> when mocked', () => { | ||
const instance = render.create( | ||
<DrawerLayoutAndroid | ||
drawerWidth={300} | ||
drawerPosition={DrawerLayoutAndroid.positions.Left} | ||
renderNavigationView={() => <View />} | ||
/>, | ||
); | ||
expect(instance).toMatchSnapshot(); | ||
}); | ||
|
||
it('should shallow render as <DrawerLayoutAndroid> when mocked', () => { | ||
const output = render.shallow( | ||
<DrawerLayoutAndroid | ||
drawerWidth={300} | ||
drawerPosition={DrawerLayoutAndroid.positions.Left} | ||
renderNavigationView={() => <View />} | ||
/>, | ||
); | ||
expect(output).toMatchSnapshot(); | ||
}); | ||
|
||
it('should shallow render as <DrawerLayoutAndroid> when not mocked', () => { | ||
jest.dontMock('DrawerLayoutAndroid'); | ||
|
||
const output = render.shallow( | ||
<DrawerLayoutAndroid | ||
drawerWidth={300} | ||
drawerPosition={DrawerLayoutAndroid.positions.Left} | ||
renderNavigationView={() => <View />} | ||
/>, | ||
); | ||
expect(output).toMatchSnapshot(); | ||
}); | ||
|
||
it('should render as <DrawerLayoutAndroid> when not mocked', () => { | ||
jest.dontMock('DrawerLayoutAndroid'); | ||
|
||
const instance = render.create( | ||
<DrawerLayoutAndroid | ||
drawerWidth={300} | ||
drawerPosition={DrawerLayoutAndroid.positions.Left} | ||
renderNavigationView={() => <View />} | ||
/>, | ||
); | ||
expect(instance).toMatchSnapshot(); | ||
}); | ||
}); |
125 changes: 125 additions & 0 deletions
125
Libraries/Components/DrawerAndroid/__tests__/__snapshots__/DrawerAndroid-test.js.snap
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,125 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<DrawerLayoutAndroid /> should render as <DrawerLayoutAndroid> when mocked 1`] = ` | ||
<AndroidDrawerLayout | ||
drawerBackgroundColor="white" | ||
drawerPosition={10} | ||
drawerWidth={300} | ||
onDrawerClose={[Function]} | ||
onDrawerOpen={[Function]} | ||
onDrawerSlide={[Function]} | ||
onDrawerStateChanged={[Function]} | ||
renderNavigationView={[Function]} | ||
style={ | ||
Array [ | ||
Object { | ||
"elevation": 16, | ||
"flex": 1, | ||
}, | ||
undefined, | ||
] | ||
} | ||
> | ||
<View | ||
collapsable={false} | ||
style={ | ||
Object { | ||
"bottom": 0, | ||
"left": 0, | ||
"position": "absolute", | ||
"right": 0, | ||
"top": 0, | ||
} | ||
} | ||
/> | ||
<View | ||
collapsable={false} | ||
style={ | ||
Array [ | ||
Object { | ||
"bottom": 0, | ||
"position": "absolute", | ||
"top": 0, | ||
}, | ||
Object { | ||
"backgroundColor": "white", | ||
"width": 300, | ||
}, | ||
] | ||
} | ||
> | ||
<View /> | ||
</View> | ||
</AndroidDrawerLayout> | ||
`; | ||
exports[`<DrawerLayoutAndroid /> should render as <DrawerLayoutAndroid> when not mocked 1`] = ` | ||
<AndroidDrawerLayout | ||
drawerBackgroundColor="white" | ||
drawerPosition={10} | ||
drawerWidth={300} | ||
onDrawerClose={[Function]} | ||
onDrawerOpen={[Function]} | ||
onDrawerSlide={[Function]} | ||
onDrawerStateChanged={[Function]} | ||
renderNavigationView={[Function]} | ||
style={ | ||
Array [ | ||
Object { | ||
"elevation": 16, | ||
"flex": 1, | ||
}, | ||
undefined, | ||
] | ||
} | ||
> | ||
<View | ||
collapsable={false} | ||
style={ | ||
Object { | ||
"bottom": 0, | ||
"left": 0, | ||
"position": "absolute", | ||
"right": 0, | ||
"top": 0, | ||
} | ||
} | ||
/> | ||
<View | ||
collapsable={false} | ||
style={ | ||
Array [ | ||
Object { | ||
"bottom": 0, | ||
"position": "absolute", | ||
"top": 0, | ||
}, | ||
Object { | ||
"backgroundColor": "white", | ||
"width": 300, | ||
}, | ||
] | ||
} | ||
> | ||
<View /> | ||
</View> | ||
</AndroidDrawerLayout> | ||
`; | ||
exports[`<DrawerLayoutAndroid /> should shallow render as <DrawerLayoutAndroid> when mocked 1`] = ` | ||
<DrawerLayoutAndroid | ||
drawerBackgroundColor="white" | ||
drawerPosition={10} | ||
drawerWidth={300} | ||
renderNavigationView={[Function]} | ||
/> | ||
`; | ||
exports[`<DrawerLayoutAndroid /> should shallow render as <DrawerLayoutAndroid> when not mocked 1`] = ` | ||
<DrawerLayoutAndroid | ||
drawerBackgroundColor="white" | ||
drawerPosition={10} | ||
drawerWidth={300} | ||
renderNavigationView={[Function]} | ||
/> | ||
`; |
Oops, something went wrong.