Download wp-calypso/apps/odyssey-stats/src/lib/test/get-api.test.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.15 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/apps/odyssey-stats/src/lib/test/get-api.test.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/apps/odyssey-stats/src/lib/test/get-api.test.js
-
curl -L -o get-api.test.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/apps/odyssey-stats/src/lib/test/get-api.test.js
1.15 kB
| import { getApiPath } from '../get-api'; | |
| const config = { | |
| isEnabled: jest.fn(), | |
| }; | |
| describe( 'getApiPath for jetpack/atomic sites', () => { | |
| beforeAll( () => { | |
| config.isEnabled.mockReturnValue( true ); | |
| } ); | |
| afterAll( () => { | |
| jest.clearAllMocks(); | |
| } ); | |
| it( 'should return the passed in jetpackPath', () => { | |
| config.isEnabled.mockReturnValue( true ); | |
| const jetpackPath = '/jetpack-api'; | |
| const params = { siteId: 123 }; | |
| const result = getApiPath( jetpackPath, params ); | |
| expect( result ).toBe( jetpackPath ); | |
| } ); | |
| } ); | |
| describe( 'getApiPath for simple sites', () => { | |
| beforeAll( () => { | |
| config.isEnabled.mockReturnValue( false ); | |
| } ); | |
| afterAll( () => { | |
| jest.clearAllMocks(); | |
| } ); | |
| it( '/site/purchases', () => { | |
| const jetpackPath = '/site/purchases'; | |
| const params = { siteId: 123 }; | |
| const result = getApiPath( jetpackPath, params ); | |
| expect( result ).toBe( `/sites/${ params.siteId }/purchases` ); | |
| } ); | |
| it( '/site', () => { | |
| const jetpackPath = '/site'; | |
| const params = { siteId: 123 }; | |
| const result = getApiPath( jetpackPath, params ); | |
| expect( result ).toBe( `/sites/${ params.siteId }` ); | |
| } ); | |
| } ); | |