Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from 'react';
- import { View } from 'react-native';
- import actions from './actions';
- export class App extends Component {
- async componentDidMount() {
- console.log('In CDM');
- await actions.funcOne();
- await actions.funcTwo();
- console.log('Finished CDM');
- }
- render() {
- return <View />;
- }
- }
- const funcOne = async () => {
- console.log('One');
- };
- const funcTwo = async () => {
- console.log('Two');
- };
- export default { asyncOne: funcOne, asyncTwo: funcTwo };
- import React from 'react';
- import { App } from '../App';
- import renderer from 'react-test-renderer';
- import actions from '../actions';
- const spyOne = jest.spyOn(actions, 'funcOne');
- const spyTwo = jest.spyOn(actions, 'funcTwo');
- describe('App ', () => {
- test('does async stuff in expected order', async () => {
- console.log('Starting test');
- const tree = await renderer.create(<App />);
- console.log('About to expect');
- expect(spyOne).toHaveBeenCalled();
- console.log('Expect one to have been called');
- expect(spyTwo).toHaveBeenCalled();
- console.log('Expect two to have been called');
- expect(tree).toMatchSnapshot();
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement