mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-26 23:05:00 +08:00
Add some Fakes for easier interaction snapshot testing
Summary: `Fake` components are simplified so snapshots are stable and reliable, and references are exported so that interactions like `onRefresh` and `onScroll` can be called manually. Currently there is just one global export for each class, but we may change this in the future if we need to manage multiple `Fake`s of the same type in one render tree. Right now these must be installed explicitly, but I might move them into `__mocks__` folders if it seems reasonable to make them defaults. Reviewed By: cpojer Differential Revision: D4318207 fbshipit-source-id: 62802353a98b09ca1c80804ef7201ea63091f94a
This commit is contained in:
committed by
Facebook Github Bot
parent
ab89b7195d
commit
5537055bf8
@@ -33,17 +33,13 @@ jest
|
||||
.mock('TextInput', () => mockComponent('TextInput'))
|
||||
.mock('Modal', () => mockComponent('Modal'))
|
||||
.mock('View', () => mockComponent('View'))
|
||||
.mock('ScrollView', () => mockComponent('ScrollView'))
|
||||
.mock('RefreshControl', () => require.requireMock('RefreshControlMock'))
|
||||
.mock('ScrollView', () => require.requireMock('ScrollViewMock'))
|
||||
.mock(
|
||||
'ActivityIndicator',
|
||||
() => mockComponent('ActivityIndicator'),
|
||||
)
|
||||
.mock('ListView', () => {
|
||||
const RealListView = require.requireActual('ListView');
|
||||
const ListView = mockComponent('ListView');
|
||||
ListView.prototype.render = RealListView.prototype.render;
|
||||
return ListView;
|
||||
})
|
||||
.mock('ListView', () => require.requireMock('ListViewMock'))
|
||||
.mock('ListViewDataSource', () => {
|
||||
const DataSource = require.requireActual('ListViewDataSource');
|
||||
DataSource.prototype.toJSON = function() {
|
||||
|
||||
Reference in New Issue
Block a user