Пример #1
0
		test( 'should run onSuccess after the last step', () => {
			const onSuccess = ( dispatch, actionList ) =>
				dispatch( { type: '%% action list success %%', actionList } );

			const actionListBefore = {
				prevSteps: [ fxt.stepASuccessful, fxt.stepBSuccessful ],
				currentStep: fxt.stepCStarted,
				nextSteps: [],
				onSuccess,
			};

			const actionListAfter = {
				prevSteps: [ fxt.stepASuccessful, fxt.stepBSuccessful, fxt.stepCSuccessful ],
				currentStep: null,
				nextSteps: [],
				onSuccess,
			};

			handleStepSuccess( store, actionListStepSuccess( actionListBefore ), fxt.time.stepCEnd );

			expect( store.dispatch ).to.not.have.been.calledWith(
				match( { type: WOOCOMMERCE_ACTION_LIST_STEP_NEXT } )
			);
			expect( store.dispatch ).to.have.been.calledWith( {
				type: '%% action list success %%',
				actionList: actionListAfter,
			} );
		} );
Пример #2
0
				onStep: ( dispatch, actionList ) => {
					const newActionList = {
						...actionList,
						data,
					};

					dispatch( { type: '%% get data %%', data } );
					dispatch( actionListStepSuccess( newActionList ) );
				},
Пример #3
0
			const step1 = { description: 'Get Data', onStep: ( dispatch, actionList ) => {
				const newActionList = {
					...actionList,
					data
				};

				dispatch( { type: '%% get data %%', data } );
				dispatch( actionListStepSuccess( newActionList ) );
			} };
Пример #4
0
			onStep: ( dispatch, actionList ) => {
				dispatch(
					deleteShippingZone(
						siteId,
						{ id: zoneId },
						actionListStepSuccess( actionList ),
						actionListStepFailure( actionList )
					)
				);
			},
Пример #5
0
			onStep: ( dispatch, actionList ) => {
				dispatch(
					updateShippingZone(
						siteId,
						zoneData,
						actionListStepSuccess( actionList ),
						actionListStepFailure( actionList )
					)
				);
			},
Пример #6
0
			onStep: ( dispatch, actionList ) => {
				dispatch(
					updateShippingZoneLocations(
						siteId,
						getZoneId( zoneId, actionList ),
						locations,
						actionListStepSuccess( actionList ),
						actionListStepFailure( actionList )
					)
				);
			},
Пример #7
0
		test( 'should ignore a success request when there is no current step.', () => {
			const actionList = {
				prevSteps: [ fxt.stepA ],
				currentStep: null,
				nextSteps: [ fxt.stepB ],
			};

			handleStepSuccess( store, actionListStepSuccess( actionList ) );

			expect( store.dispatch ).to.not.have.been.called;
		} );
Пример #8
0
			onStep: ( dispatch, actionList ) => {
				dispatch(
					updateWcsShippingZoneMethod(
						siteId,
						getMethodId( id, actionList ),
						realMethodType,
						extraMethodProps,
						actionListStepSuccess( actionList ),
						actionListStepFailure( actionList )
					)
				);
			},
Пример #9
0
			onStep: ( dispatch, actionList ) => {
				recordTrack( 'calypso_woocommerce_shipping_method_deleted', {
					shipping_method: methodType,
				} );
				dispatch(
					deleteShippingZoneMethod(
						siteId,
						zoneId,
						method.id,
						actionListStepSuccess( actionList ),
						actionListStepFailure( actionList )
					)
				);
			},
Пример #10
0
		test( 'should run the first step in the list', () => {
			const actionListBefore = {
				nextSteps: [ fxt.stepA, fxt.stepB, fxt.stepC ],
			};

			const actionListAfter = {
				prevSteps: undefined,
				currentStep: fxt.stepAStarted,
				nextSteps: [ fxt.stepB, fxt.stepC ],
			};

			handleStepNext( store, actionListStepNext( actionListBefore ), fxt.time.stepAStart );

			expect( store.dispatch ).to.have.been.calledWith( { type: '%% action a %%' } );
			expect( store.dispatch ).to.have.been.calledWith( actionListStepSuccess( actionListAfter ) );
		} );
Пример #11
0
		test( 'should complete the middle step in the list and call last step', () => {
			const actionListBefore = {
				prevSteps: [ fxt.stepASuccessful ],
				currentStep: fxt.stepBStarted,
				nextSteps: [ fxt.stepC ],
			};

			const actionListAfter = {
				prevSteps: [ fxt.stepASuccessful, fxt.stepBSuccessful ],
				currentStep: null,
				nextSteps: [ fxt.stepC ],
			};

			handleStepSuccess( store, actionListStepSuccess( actionListBefore ), fxt.time.stepBEnd );

			expect( store.dispatch ).to.have.been.calledWith( actionListStepNext( actionListAfter ) );
		} );
Пример #12
0
		test( 'should annotate the actionList to the reducer state', () => {
			const actionListBefore = {
				prevSteps: [],
				currentStep: fxt.stepAStarted,
				nextSteps: [ fxt.stepB, fxt.stepC ],
			};

			const actionListAfter = {
				prevSteps: [ fxt.stepASuccessful ],
				currentStep: null,
				nextSteps: [ fxt.stepB, fxt.stepC ],
			};

			handleStepSuccess( store, actionListStepSuccess( actionListBefore ), fxt.time.stepAEnd );

			expect( store.dispatch ).to.have.been.calledWith( actionListAnnotate( actionListAfter ) );
		} );
Пример #13
0
const createShippingZoneMethodSuccess = actionList => (
	dispatch,
	getState,
	{ sentData, receivedData }
) => {
	const methodIdMapping = {
		...actionList.methodIdMapping,
		[ sentData.id.index ]: receivedData.id,
	};

	const newActionList = {
		...actionList,
		methodIdMapping,
	};

	dispatch( actionListStepSuccess( newActionList ) );
};
Пример #14
0
		it( 'should run a last step in the list', () => {
			const actionListBefore = {
				prevSteps: [ fxt.stepASuccessful, fxt.stepBSuccessful ],
				currentStep: null,
				nextSteps: [ fxt.stepC ],
			};

			const actionListAfter = {
				prevSteps: [ fxt.stepASuccessful, fxt.stepBSuccessful ],
				currentStep: fxt.stepCStarted,
				nextSteps: [],
			};

			handleStepNext( store, actionListStepNext( actionListBefore ), fxt.time.stepCStart );

			expect( store.dispatch ).to.have.been.calledWith( { type: '%% action c %%' } );
			expect( store.dispatch ).to.have.been.calledWith( actionListStepSuccess( actionListAfter ) );
		} );
Пример #15
0
			onStep: ( dispatch, actionList ) => {
				if ( isNew || enabledChanged ) {
					const event =
						false !== enabled
							? 'calypso_woocommerce_shipping_method_enabled'
							: 'calypso_woocommerce_shipping_method_disabled';
					recordTrack( event, { shipping_method: realMethodType } );
				}

				dispatch(
					updateShippingZoneMethod(
						siteId,
						getZoneId( zoneId, actionList ),
						getMethodId( id, actionList ),
						methodPropsToUpdate,
						actionListStepSuccess( actionList ),
						actionListStepFailure( actionList )
					)
				);
			},
Пример #16
0
			onStep: ( dispatch, actionList ) => {
				analytics.tracks.recordEvent( 'calypso_woocommerce_shipping_method_enabled', {
					shipping_method: methodType,
				} );
				dispatch( actionListStepSuccess( actionList ) );
			},
Пример #17
0
				.then( () => dispatch( actionListStepSuccess( actionList ) ) )
Пример #18
0
			onStep: ( dispatch, actionList ) => {
				recordTrack( 'calypso_woocommerce_shipping_method_enabled', {
					shipping_method: methodType,
				} );
				dispatch( actionListStepSuccess( actionList ) );
			},
Пример #19
0
				onStep: ( dispatch, actionList ) => {
					dispatch( { type: '%% use data %%', data } );
					dispatch( actionListStepSuccess( actionList ) );
				},
Пример #20
0
			const step2 = { description: 'Use Data', onStep: ( dispatch, actionList ) => {
				dispatch( { type: '%% use data %%', data } );
				dispatch( actionListStepSuccess( actionList ) );
			} };
Пример #21
0
export const stepC = { description: 'Do Step C', onStep: ( dispatch, actionList ) => {
	dispatch( { type: '%% action c %%' } );
	dispatch( actionListStepSuccess( actionList ) );
} };