-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stepper: Leave checkout bring you to site-setup in onboarding (#97244)
* Leave cart bring you to site-setup in onboarding * Do not touch Start * Use function already in Start, adds tests * Renamed test * Fix tests * Unused code * Add skippedCheckout
- Loading branch information
1 parent
f9ebb75
commit 227c0c1
Showing
5 changed files
with
64 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import config from '@automattic/calypso-config'; | ||
|
||
export function pathToUrl( path: string ) { | ||
if ( config( 'env' ) !== 'production' ) { | ||
const protocol = config( 'protocol' ) ?? 'https'; | ||
const port = config( 'port' ) ? ':' + config( 'port' ) : ''; | ||
const hostName = config( 'hostname' ); | ||
|
||
return `${ protocol }://${ hostName }${ port }${ path }`; | ||
} | ||
|
||
return `https://${ config( 'hostname' ) }${ path }`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import config from '@automattic/calypso-config'; | ||
import { pathToUrl } from '../path-to-url'; | ||
|
||
jest.mock( '@automattic/calypso-config', () => jest.fn() ); | ||
|
||
const mockConfig = config as unknown as jest.Mock; | ||
|
||
describe( 'pathToUrl', () => { | ||
beforeEach( () => { | ||
mockConfig.mockReset(); | ||
} ); | ||
|
||
test( 'should return production URL', () => { | ||
mockConfig.mockImplementation( ( key: string ) => { | ||
switch ( key ) { | ||
case 'env': | ||
return 'production'; | ||
case 'hostname': | ||
return 'wordpress.com'; | ||
default: | ||
return undefined; | ||
} | ||
} ); | ||
|
||
expect( pathToUrl( '/start' ) ).toBe( 'https://wordpress.com/start' ); | ||
} ); | ||
|
||
test( 'should return development URL', () => { | ||
mockConfig.mockImplementation( ( key: string ) => { | ||
switch ( key ) { | ||
case 'env': | ||
return 'development'; | ||
case 'protocol': | ||
return 'http'; | ||
case 'hostname': | ||
return 'calypso.localhost'; | ||
case 'port': | ||
return '3000'; | ||
default: | ||
return undefined; | ||
} | ||
} ); | ||
|
||
expect( pathToUrl( '/start' ) ).toBe( 'http://calypso.localhost:3000/start' ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters