Download wp-calypso/client/landing/stepper/utils/test/skip-launchpad.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.6 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/landing/stepper/utils/test/skip-launchpad.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/landing/stepper/utils/test/skip-launchpad.ts
-
curl -L -o skip-launchpad.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/landing/stepper/utils/test/skip-launchpad.ts
1.6 kB
| /** | |
| * @jest-environment jsdom | |
| */ | |
| // @ts-nocheck - TODO: Fix TypeScript issues | |
| import { updateLaunchpadSettings } from '@automattic/data-stores'; | |
| import { skipLaunchpad } from '../skip-launchpad'; | |
| // Mock the data-stores module | |
| jest.mock( '@automattic/data-stores', () => ( { | |
| updateLaunchpadSettings: jest.fn(), | |
| } ) ); | |
| describe( 'skipLaunchpad', () => { | |
| beforeEach( () => { | |
| // Clear all mocks before each test | |
| jest.clearAllMocks(); | |
| // Properly mock window.location | |
| delete window.location; | |
| window.location = { assign: jest.fn() } as unknown as Location; | |
| } ); | |
| it( 'should update launchpad settings and redirect to siteId by default', async () => { | |
| await skipLaunchpad( { siteId: '123', siteSlug: null } ); | |
| expect( updateLaunchpadSettings ).toHaveBeenCalledWith( '123', { | |
| launchpad_screen: 'skipped', | |
| } ); | |
| expect( window.location.assign ).toHaveBeenCalledWith( '/home/123' ); | |
| } ); | |
| it( 'should update launchpad settings and redirect to siteSlug by default', async () => { | |
| await skipLaunchpad( { siteId: null, siteSlug: 'test-site' } ); | |
| expect( updateLaunchpadSettings ).toHaveBeenCalledWith( 'test-site', { | |
| launchpad_screen: 'skipped', | |
| } ); | |
| expect( window.location.assign ).toHaveBeenCalledWith( '/home/test-site' ); | |
| } ); | |
| it( 'should not redirect when redirectToHome is false', async () => { | |
| await skipLaunchpad( { siteId: '123', siteSlug: null, redirectToHome: false } ); | |
| expect( updateLaunchpadSettings ).toHaveBeenCalledWith( '123', { | |
| launchpad_screen: 'skipped', | |
| } ); | |
| expect( window.location.assign ).not.toHaveBeenCalled(); | |
| } ); | |
| } ); | |