File size: 1,555 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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
import { CONCIERGE_INITIAL_REQUEST } from 'calypso/state/action-types';
import { updateConciergeInitial } from 'calypso/state/concierge/actions';
import { http } from 'calypso/state/data-layer/wpcom-http/actions';
import {
conciergeInitialFetchError,
fetchConciergeInitial,
storeFetchedConciergeInitial,
showConciergeInitialFetchError,
} from '../';
describe( 'wpcom-api', () => {
let originalRandomUUID;
beforeAll( () => {
originalRandomUUID = global.crypto.randomUUID;
global.crypto.randomUUID = () => 'fake-uuid';
} );
afterAll( () => {
global.crypto.randomUUID = originalRandomUUID;
} );
describe( 'concierge', () => {
test( 'fetchConciergeInitial()', () => {
const action = {
type: CONCIERGE_INITIAL_REQUEST,
siteId: 999,
};
expect( fetchConciergeInitial( action ) ).toEqual(
http(
{
method: 'GET',
path: '/concierge/initial',
apiNamespace: 'wpcom/v2',
query: {
site_id: action.siteId,
},
},
action
)
);
} );
test( 'storeFetchedConciergeInitial()', () => {
const mockInitial = {
available_times: [
new Date( '2017-01-01 01:00:00' ),
new Date( '2017-01-01 02:00:00' ),
new Date( '2017-01-01 03:00:00' ),
],
schedule_id: 18,
};
expect( storeFetchedConciergeInitial( {}, mockInitial ) ).toEqual(
updateConciergeInitial( mockInitial )
);
} );
test( 'showConciergeInitialFetchError()', () => {
expect( showConciergeInitialFetchError() ).toEqual( conciergeInitialFetchError() );
} );
} );
} );
|