File size: 1,238 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
 * @jest-environment jsdom
 */
// @ts-nocheck - TODO: Fix TypeScript issues

import { render } from '@testing-library/react';
import React from 'react';
import { Provider } from 'react-redux';
import configureStore from 'redux-mock-store';
import { thunk } from 'redux-thunk';
import * as queryProductsList from 'calypso/components/data/query-products-list';
import EmailStep from '../index';

const initialState = {
	flowName: 'test:flow',
	stepName: 'test:step2',
	sites: {
		items: {
			1: {},
		},
	},
	ui: {},
	productsList: {
		isFetching: false,
	},
};

const productListQuerySpy = jest.spyOn( queryProductsList, 'default' );

describe( 'Email Step', () => {
	test( 'should request a complete product list', () => {
		const middlewares = [ thunk ];
		const mockStore = configureStore( middlewares );
		const store = mockStore( initialState );

		render(
			<Provider store={ store }>
				<EmailStep flowName="test:flow" stepName="test:step2" />
			</Provider>
		);

		// An empty first argument means we're fetching all products, so we'll
		// have access to email product data. The second empty prop represents
		// the React children (we have none).
		expect( productListQuerySpy ).toHaveBeenCalledWith( {}, {} );
	} );
} );