File size: 1,755 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 |
import { http } from 'calypso/state/data-layer/wpcom-http/actions';
import { errorNotice, successNotice } from 'calypso/state/notices/actions';
import { transferPlanOwnership } from 'calypso/state/sites/plans/actions';
import { handleTransferError, handleTransferSuccess, requestPlanOwnershipTransfer } from '../';
const siteId = 2916284;
describe( 'requestPlanOwnershipTransfer()', () => {
test( 'should return an action for HTTP request to transfer the site plan to another user', () => {
const newOwnerUserId = 12345678;
const action = transferPlanOwnership( siteId, newOwnerUserId );
const result = requestPlanOwnershipTransfer( action );
expect( result ).toEqual(
http(
{
apiVersion: '1',
method: 'POST',
path: '/sites/' + action.siteId + '/plan-transfer',
query: {
new_user_id: action.newOwnerUserId,
},
},
action
)
);
} );
} );
describe( 'handleTransferSuccess()', () => {
test( 'should return a success notice action and a function', () => {
const actions = handleTransferSuccess( { siteId } );
expect( actions ).toHaveLength( 2 );
expect( actions[ 0 ] ).toMatchObject(
successNotice( 'Plan purchaser has been changed successfully.', {
duration: 8000,
id: `sites-plan-transfer-notice-${ siteId }`,
} )
);
expect( actions[ 1 ] ).toBeInstanceOf( Function );
} );
} );
describe( 'handleTransferError()', () => {
test( 'should return an error notice action', () => {
const message = 'Transferring plans is not allowed for this site.';
const action = handleTransferError( { siteId }, { message } );
expect( action ).toMatchObject(
errorNotice( message, {
duration: 8000,
id: `sites-plan-transfer-notice-${ siteId }`,
} )
);
} );
} );
|