-
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.
Fix URL in case it does not have the http protocol (#94208)
- Loading branch information
Showing
2 changed files
with
64 additions
and
4 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
...clarative-flow/internals/steps-repository/site-migration-instructions/steps/test/utils.ts
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,49 @@ | ||
import { getPluginInstallationPage, getMigrateGuruPageURL } from '../utils'; | ||
|
||
describe( 'utils', () => { | ||
describe( 'getPluginInstallationPage', () => { | ||
it( 'should return WordPress.org plugin page if fromUrl is empty', () => { | ||
expect( getPluginInstallationPage( '' ) ).toBe( | ||
'https://wordpress.org/plugins/migrate-guru/' | ||
); | ||
} ); | ||
|
||
it( 'should return correct plugin installation page for given URL', () => { | ||
expect( getPluginInstallationPage( 'example.com' ) ).toBe( | ||
'https://example.com/wp-admin/plugin-install.php?s=%2522migrate%2520guru%2522&tab=search&type=term' | ||
); | ||
} ); | ||
|
||
it( 'should handle URLs with existing protocol', () => { | ||
expect( getPluginInstallationPage( 'http://example.com' ) ).toBe( | ||
'http://example.com/wp-admin/plugin-install.php?s=%2522migrate%2520guru%2522&tab=search&type=term' | ||
); | ||
} ); | ||
|
||
it( 'should remove duplicate slashes from the URL', () => { | ||
expect( getPluginInstallationPage( 'https://example.com///' ) ).toBe( | ||
'https://example.com/wp-admin/plugin-install.php?s=%2522migrate%2520guru%2522&tab=search&type=term' | ||
); | ||
} ); | ||
} ); | ||
|
||
describe( 'getMigrateGuruPageURL', () => { | ||
it( 'should return correct Migrate Guru page URL', () => { | ||
expect( getMigrateGuruPageURL( 'example.com' ) ).toBe( | ||
'https://example.com/wp-admin/admin.php?page=migrateguru' | ||
); | ||
} ); | ||
|
||
it( 'should handle URLs with existing protocol', () => { | ||
expect( getMigrateGuruPageURL( 'http://example.com' ) ).toBe( | ||
'http://example.com/wp-admin/admin.php?page=migrateguru' | ||
); | ||
} ); | ||
|
||
it( 'should remove duplicate slashes from the URL', () => { | ||
expect( getMigrateGuruPageURL( 'https://example.com///' ) ).toBe( | ||
'https://example.com/wp-admin/admin.php?page=migrateguru' | ||
); | ||
} ); | ||
} ); | ||
} ); |
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