Download wp-calypso/client/state/guided-tours/test/contexts.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/guided-tours/test/contexts.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/state/guided-tours/test/contexts.js
-
curl -L -o contexts.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/guided-tours/test/contexts.js
1 kB
| /** | |
| * @jest-environment jsdom | |
| */ | |
| import moment from 'moment'; | |
| import { isUserNewerThan } from '../contexts'; | |
| jest.mock( 'calypso/layout/guided-tours/config', () => { | |
| return require( 'calypso/state/guided-tours/test/fixtures/config' ); | |
| } ); | |
| const WEEK_IN_MILLISECONDS = 7 * 1000 * 3600 * 24; | |
| describe( 'selectors', () => { | |
| describe( '#isUserNewerThan', () => { | |
| const oldUser = { | |
| currentUser: { | |
| id: 73705554, | |
| user: { ID: 73705554, login: 'testonesite2016', date: moment().subtract( 8, 'days' ) }, | |
| }, | |
| }; | |
| const newUser = { | |
| currentUser: { | |
| id: 73705554, | |
| user: { ID: 73705554, login: 'testonesite2016', date: moment() }, | |
| }, | |
| }; | |
| test( 'should return false for users registered before a week ago', () => { | |
| expect( isUserNewerThan( WEEK_IN_MILLISECONDS )( oldUser ) ).toBe( false ); | |
| } ); | |
| test( 'should return true for users registered in the last week', () => { | |
| expect( isUserNewerThan( WEEK_IN_MILLISECONDS )( newUser ) ).toBe( true ); | |
| } ); | |
| } ); | |
| } ); | |