react-code-dataset / wp-calypso /client /state /data-layer /wpcom /active-promotions /test /index.js
react-code-dataset / wp-calypso /client /state /data-layer /wpcom /active-promotions /test /index.js
Download wp-calypso/client/state/data-layer/wpcom/active-promotions/test/index.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.65 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/data-layer/wpcom/active-promotions/test/index.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/state/data-layer/wpcom/active-promotions/test/index.js
-
curl -L -o index.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/data-layer/wpcom/active-promotions/test/index.js
1.65 kB
| import { | |
| activePromotionsReceiveAction, | |
| activePromotionsRequestFailureAction, | |
| activePromotionsRequestSuccessAction, | |
| } from 'calypso/state/active-promotions/actions'; | |
| import { WPCOM_RESPONSE } from 'calypso/state/active-promotions/test/fixture'; | |
| import { http } from 'calypso/state/data-layer/wpcom-http/actions'; | |
| import { receiveActivePromotions, receiveError, requestActivePromotions } from '../'; | |
| describe( 'wpcom-api', () => { | |
| describe( 'active promotions request', () => { | |
| describe( '#requestActivePromotions', () => { | |
| test( 'should return HTTP request to active-promotions endpoint', () => { | |
| const action = { type: 'DUMMY' }; | |
| expect( requestActivePromotions( action ) ).toEqual( | |
| http( | |
| { | |
| apiVersion: '1.1', | |
| method: 'GET', | |
| path: '/me/active-promotions', | |
| }, | |
| action | |
| ) | |
| ); | |
| } ); | |
| } ); | |
| describe( '#receiveActivePromotions', () => { | |
| test( 'should return active promotions', () => { | |
| const activePromotions = WPCOM_RESPONSE; | |
| const action = activePromotionsReceiveAction( activePromotions ); | |
| expect( | |
| receiveActivePromotions( action, { active_promotions: activePromotions } ) | |
| ).toEqual( [ | |
| activePromotionsRequestSuccessAction(), | |
| activePromotionsReceiveAction( activePromotions ), | |
| ] ); | |
| } ); | |
| } ); | |
| describe( '#receiveError', () => { | |
| test( 'should return error', () => { | |
| const error = 'could not find active promotions'; | |
| const action = activePromotionsRequestFailureAction( error ); | |
| expect( receiveError( action, error ) ).toEqual( | |
| activePromotionsRequestFailureAction( error ) | |
| ); | |
| } ); | |
| } ); | |
| } ); | |
| } ); | |