Download wp-calypso/client/state/selectors/test/can-current-user.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 969 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/selectors/test/can-current-user.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/state/selectors/test/can-current-user.js
-
curl -L -o can-current-user.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/selectors/test/can-current-user.js
969 Bytes
| import { canCurrentUser } from 'calypso/state/selectors/can-current-user'; | |
| describe( 'canCurrentUser()', () => { | |
| test( 'should return null if the site is not known', () => { | |
| const isCapable = canCurrentUser( | |
| { | |
| currentUser: { | |
| capabilities: {}, | |
| }, | |
| }, | |
| 2916284, | |
| 'manage_options' | |
| ); | |
| expect( isCapable ).toBeNull(); | |
| } ); | |
| test( 'should return the value for the specified capability', () => { | |
| const isCapable = canCurrentUser( | |
| { | |
| currentUser: { | |
| capabilities: { | |
| 2916284: { | |
| manage_options: false, | |
| }, | |
| }, | |
| }, | |
| }, | |
| 2916284, | |
| 'manage_options' | |
| ); | |
| expect( isCapable ).toBe( false ); | |
| } ); | |
| test( 'should return false if the capability is invalid', () => { | |
| const isCapable = canCurrentUser( | |
| { | |
| currentUser: { | |
| capabilities: { | |
| 2916284: { | |
| manage_options: false, | |
| }, | |
| }, | |
| }, | |
| }, | |
| 2916284, | |
| 'manage_foo' | |
| ); | |
| expect( isCapable ).toBe( false ); | |
| } ); | |
| } ); | |