Ejemplo n.º 1
0
		test( 'should keep track of pending comment actions', () => {
			const approveAction = {
				type: COMMENTS_CHANGE_STATUS,
				commentId: 1,
				status: 'approved',
				meta: {
					dataLayer: {
						trackRequest: true,
					},
				},
			};
			const deleteComment = {
				type: COMMENTS_DELETE,
				commentId: 2,
				meta: {
					dataLayer: {
						trackRequest: true,
					},
				},
			};
			const state = deepFreeze( [ getRequestKey( approveAction ) ] );
			const nextState = pendingActions( state, deleteComment );
			expect( nextState ).toEqual( [
				getRequestKey( approveAction ),
				getRequestKey( deleteComment ),
			] );
		} );
Ejemplo n.º 2
0
		test( 'should keep track of pending comment action', () => {
			const action = {
				type: COMMENTS_CHANGE_STATUS,
				commentId: 1,
				status: 'approved',
				meta: {
					dataLayer: {
						trackRequest: true,
					},
				},
			};
			const state = pendingActions( undefined, action );
			expect( state ).toEqual( [ getRequestKey( action ) ] );
		} );
	test( 'should return false if that site is not known', () => {
		const siteId = 87654321;
		const action = requestJetpackSettings( 12345678 );
		const state = {
			dataRequests: {
				[ getRequestKey( action ) ]: {
					status: 'pending',
				},
			},
		};

		const output = isRequestingJetpackSettings( state, siteId );
		expect( output ).toBe( false );
	} );
	test( 'should return false if settings are currently not being requested', () => {
		const siteId = 87654321;
		const action = requestJetpackSettings( siteId );
		const state = {
			dataRequests: {
				[ getRequestKey( action ) ]: {
					status: 'success',
				},
			},
		};

		const output = isRequestingJetpackSettings( state, siteId );
		expect( output ).toBe( false );
	} );
	test( 'should return false if settings are currently being requested for matching site ID and non-matching query', () => {
		const siteId = 87654321;
		const query = { foo: 'bar' };
		const action = requestJetpackSettings( siteId, { foo: 'baz' } );
		const state = {
			dataRequests: {
				[ getRequestKey( action ) ]: {
					status: 'pending',
				},
			},
		};

		const output = isRequestingJetpackSettings( state, siteId, query );
		expect( output ).toBe( false );
	} );
Ejemplo n.º 6
0
		test( 'clears current pending requests when we detect a fresh view', () => {
			const action = {
				type: COMMENTS_CHANGE_STATUS,
				commentId: 1,
				status: 'approved',
				meta: {
					dataLayer: {
						trackRequest: true,
					},
				},
			};
			const state = pendingActions( deepFreeze( [ getRequestKey( action ) ] ), {
				type: COMMENTS_LIST_REQUEST,
			} );
			expect( state ).toEqual( [] );
		} );