Download wp-calypso/client/boot/test/geolocation.test.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 988 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/boot/test/geolocation.test.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/boot/test/geolocation.test.ts
-
curl -L -o geolocation.test.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/boot/test/geolocation.test.ts
988 Bytes
| /** | |
| * @jest-environment jsdom | |
| */ | |
| import { setGeoLocation } from '@automattic/number-formatters'; | |
| import { setupCountryCode } from '../geolocation'; | |
| jest.mock( '@automattic/number-formatters', () => ( { | |
| setGeoLocation: jest.fn(), | |
| } ) ); | |
| describe( 'setupCountryCode', () => { | |
| beforeEach( () => { | |
| jest.resetAllMocks(); | |
| document.cookie = ''; | |
| } ); | |
| test( 'should use country_code from cookie and set geo location correctly', async () => { | |
| document.cookie = 'country_code=US'; | |
| await setupCountryCode(); | |
| expect( setGeoLocation ).toHaveBeenCalledWith( 'US' ); | |
| } ); | |
| test( 'should not set location if cookie has unknown country', async () => { | |
| document.cookie = 'country_code=unknown'; | |
| await setupCountryCode(); | |
| expect( setGeoLocation ).not.toHaveBeenCalled(); | |
| } ); | |
| test( 'should not set location if country_code cookie is not set', async () => { | |
| document.cookie = ''; | |
| await setupCountryCode(); | |
| expect( setGeoLocation ).not.toHaveBeenCalled(); | |
| } ); | |
| } ); | |