mirror of
https://github.com/callstack/react-native-testing-library.git
synced 2026-09-18 23:09:04 +08:00
Update flow-bin to the latest version 🚀 (#183)
* chore(package): update flow-bin to version 0.99.0 * chore(package): update lockfile yarn.lock * Fix flow
This commit is contained in:
committed by
Michał Pierzchała
parent
9227012e45
commit
2c181b844e
@@ -6,6 +6,8 @@ import stripAnsi from 'strip-ansi';
|
||||
import { debug, render, fireEvent, flushMicrotasksQueue } from '..';
|
||||
import debugShallow from '../helpers/debugShallow';
|
||||
|
||||
type ConsoleLogMock = JestMockFn<Array<string>, void>;
|
||||
|
||||
function TextComponent({ text }) {
|
||||
return <Text>{text}</Text>;
|
||||
}
|
||||
@@ -30,17 +32,16 @@ class Button extends React.Component<*, *> {
|
||||
}
|
||||
|
||||
test('debug', () => {
|
||||
// $FlowFixMe
|
||||
console.log = jest.fn();
|
||||
jest.spyOn(console, 'log').mockImplementation(x => x);
|
||||
const component = <Button onPress={jest.fn} text="Press me" />;
|
||||
debug(component);
|
||||
|
||||
const output = console.log.mock.calls[0][0];
|
||||
const output = (console.log: ConsoleLogMock).mock.calls[0][0];
|
||||
|
||||
expect(stripAnsi(output)).not.toEqual(output);
|
||||
expect(stripAnsi(output)).toMatchSnapshot();
|
||||
|
||||
console.log.mockReset();
|
||||
(console.log: ConsoleLogMock).mockReset();
|
||||
|
||||
debug(component, 'test message');
|
||||
|
||||
@@ -57,12 +58,12 @@ test('debug.deep', () => {
|
||||
const component = <Button onPress={jest.fn} text="Press me" />;
|
||||
debug.deep(component);
|
||||
|
||||
const output = console.log.mock.calls[0][0];
|
||||
const output = (console.log: ConsoleLogMock).mock.calls[0][0];
|
||||
|
||||
expect(stripAnsi(output)).not.toEqual(output);
|
||||
expect(stripAnsi(output)).toMatchSnapshot();
|
||||
|
||||
console.log.mockReset();
|
||||
(console.log: ConsoleLogMock).mockReset();
|
||||
|
||||
debug.deep(component, 'test message');
|
||||
|
||||
@@ -81,7 +82,7 @@ test('debug.deep async test', async () => {
|
||||
|
||||
debug.deep(toJSON());
|
||||
|
||||
const output = console.log.mock.calls[0][0];
|
||||
const output = (console.log: ConsoleLogMock).mock.calls[0][0];
|
||||
|
||||
expect(stripAnsi(output)).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@@ -11,6 +11,8 @@ import {
|
||||
import stripAnsi from 'strip-ansi';
|
||||
import { render, fireEvent } from '..';
|
||||
|
||||
type ConsoleLogMock = JestMockFn<Array<string>, void>;
|
||||
|
||||
const PLACEHOLDER_FRESHNESS = 'Add custom freshness';
|
||||
const PLACEHOLDER_CHEF = 'Who inspected freshness?';
|
||||
|
||||
@@ -269,7 +271,7 @@ test('debug', () => {
|
||||
debug.shallow('my other custom message');
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
const mockCalls = console.log.mock.calls;
|
||||
const mockCalls = (console.log: ConsoleLogMock).mock.calls;
|
||||
|
||||
expect(stripAnsi(mockCalls[0][0])).toMatchSnapshot();
|
||||
expect(stripAnsi(mockCalls[1][0] + mockCalls[1][1])).toMatchSnapshot(
|
||||
@@ -291,7 +293,7 @@ test('debug changing component', () => {
|
||||
debug();
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
const mockCalls = console.log.mock.calls;
|
||||
const mockCalls = (console.log: ConsoleLogMock).mock.calls;
|
||||
|
||||
expect(stripAnsi(mockCalls[4][0])).toMatchSnapshot(
|
||||
'bananaFresh button message should now be "fresh"'
|
||||
|
||||
Reference in New Issue
Block a user