Download wp-calypso/packages/data-stores/src/user/test/reducer.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.02 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/data-stores/src/user/test/reducer.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/packages/data-stores/src/user/test/reducer.ts
-
curl -L -o reducer.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/packages/data-stores/src/user/test/reducer.ts
1.02 kB
| /* | |
| * These tests shouldn't require the jsdom environment, | |
| * but we're waiting for this PR to merge: | |
| * https://github.com/WordPress/gutenberg/pull/20486 | |
| * | |
| * @jest-environment jsdom | |
| */ | |
| import { createActions } from '../actions'; | |
| import { currentUser } from '../reducer'; | |
| const { receiveCurrentUser, receiveCurrentUserFailed } = createActions(); | |
| describe( 'currentUser', () => { | |
| it( 'defaults to undefined', () => { | |
| const state = currentUser( undefined, { type: 'TEST_ACTION' } ); | |
| expect( state ).toBe( undefined ); | |
| } ); | |
| it( 'returns a current user object', () => { | |
| const testUser = { | |
| ID: 1, | |
| username: 'testusername', | |
| display_name: 'testusername', | |
| language: 'en', | |
| locale_variant: '', | |
| }; | |
| const state = currentUser( undefined, receiveCurrentUser( testUser ) ); | |
| expect( state ).toEqual( testUser ); | |
| } ); | |
| it( 'returns null if receiving the current user failed', () => { | |
| const state = currentUser( undefined, receiveCurrentUserFailed() ); | |
| expect( state ).toBe( null ); | |
| } ); | |
| } ); | |