Download wp-calypso/client/state/selectors/test/count-post-likes.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 945 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/selectors/test/count-post-likes.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/state/selectors/test/count-post-likes.js
-
curl -L -o count-post-likes.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/selectors/test/count-post-likes.js
945 Bytes
| import { countPostLikes } from 'calypso/state/posts/selectors/count-post-likes'; | |
| describe( 'countPostLikes()', () => { | |
| test( 'should return null if the site has never been fetched', () => { | |
| const count = countPostLikes( | |
| { | |
| posts: { | |
| likes: { | |
| items: {}, | |
| }, | |
| }, | |
| }, | |
| 12345678, | |
| 50 | |
| ); | |
| expect( count ).toBeNull(); | |
| } ); | |
| test( 'should return null if the post has never been fetched', () => { | |
| const count = countPostLikes( | |
| { | |
| posts: { | |
| likes: { | |
| items: { | |
| 12345678: { | |
| 10: { found: 42 }, | |
| }, | |
| }, | |
| }, | |
| }, | |
| }, | |
| 12345678, | |
| 50 | |
| ); | |
| expect( count ).toBeNull(); | |
| } ); | |
| test( 'should return the total of post likes', () => { | |
| const count = countPostLikes( | |
| { | |
| posts: { | |
| likes: { | |
| items: { | |
| 12345678: { | |
| 50: { found: 42 }, | |
| }, | |
| }, | |
| }, | |
| }, | |
| }, | |
| 12345678, | |
| 50 | |
| ); | |
| expect( count ).toEqual( 42 ); | |
| } ); | |
| } ); | |