2015-03-25 05:34:12 +03:00
|
|
|
/**
|
2018-09-12 01:27:47 +03:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2015-03-25 05:34:12 +03:00
|
|
|
*
|
2018-02-17 05:24:55 +03:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2015-11-18 19:25:30 +03:00
|
|
|
*
|
2018-05-11 01:44:55 +03:00
|
|
|
* @format
|
2015-11-18 19:25:30 +03:00
|
|
|
* @flow
|
2015-03-25 05:34:12 +03:00
|
|
|
*/
|
2018-05-11 01:44:55 +03:00
|
|
|
|
2015-03-25 05:34:12 +03:00
|
|
|
'use strict';
|
|
|
|
|
2018-05-14 10:09:36 +03:00
|
|
|
const React = require('react');
|
|
|
|
const ReactNative = require('react-native');
|
2019-08-09 20:06:53 +03:00
|
|
|
|
2018-05-14 10:09:36 +03:00
|
|
|
const requestAnimationFrame = require('fbjs/lib/requestAnimationFrame');
|
2015-11-18 19:25:30 +03:00
|
|
|
|
2018-05-14 10:09:36 +03:00
|
|
|
const {StyleSheet, View} = ReactNative;
|
|
|
|
const {TestModule} = ReactNative.NativeModules;
|
2015-03-25 05:34:12 +03:00
|
|
|
|
2017-08-18 04:36:54 +03:00
|
|
|
class SimpleSnapshotTest extends React.Component<{}> {
|
2015-03-25 05:34:12 +03:00
|
|
|
componentDidMount() {
|
|
|
|
if (!TestModule.verifySnapshot) {
|
|
|
|
throw new Error('TestModule.verifySnapshot not defined.');
|
|
|
|
}
|
|
|
|
requestAnimationFrame(() => TestModule.verifySnapshot(this.done));
|
2016-07-26 11:00:02 +03:00
|
|
|
}
|
2015-03-25 05:34:12 +03:00
|
|
|
|
2019-08-09 20:06:53 +03:00
|
|
|
done: (success: boolean) => void = (success: boolean) => {
|
2015-06-17 17:09:23 +03:00
|
|
|
TestModule.markTestPassed(success);
|
2016-07-26 11:00:02 +03:00
|
|
|
};
|
2015-03-25 05:34:12 +03:00
|
|
|
|
2019-08-09 20:06:53 +03:00
|
|
|
render(): React.Node {
|
2015-03-25 05:34:12 +03:00
|
|
|
return (
|
2018-11-07 00:48:40 +03:00
|
|
|
<View style={styles.container}>
|
2015-03-25 05:34:12 +03:00
|
|
|
<View style={styles.box1} />
|
|
|
|
<View style={styles.box2} />
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
2016-07-26 11:00:02 +03:00
|
|
|
}
|
2015-03-25 05:34:12 +03:00
|
|
|
|
2018-05-14 10:09:36 +03:00
|
|
|
const styles = StyleSheet.create({
|
2018-11-07 00:48:40 +03:00
|
|
|
container: {
|
|
|
|
backgroundColor: 'white',
|
|
|
|
padding: 100,
|
|
|
|
},
|
2015-03-25 05:34:12 +03:00
|
|
|
box1: {
|
|
|
|
width: 80,
|
|
|
|
height: 50,
|
|
|
|
backgroundColor: 'red',
|
|
|
|
},
|
|
|
|
box2: {
|
|
|
|
top: -10,
|
|
|
|
left: 20,
|
|
|
|
width: 70,
|
|
|
|
height: 90,
|
|
|
|
backgroundColor: 'blue',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2015-06-24 05:12:51 +03:00
|
|
|
SimpleSnapshotTest.displayName = 'SimpleSnapshotTest';
|
|
|
|
|
2015-03-25 05:34:12 +03:00
|
|
|
module.exports = SimpleSnapshotTest;
|