-
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 isPartnerSignupQuery URIError (#86514)
- Loading branch information
Showing
2 changed files
with
64 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { isPartnerSignupQuery } from '../utils'; | ||
|
||
describe( 'isPartnerSignupQuery', () => { | ||
it( 'should return false when currentQuery is undefined', () => { | ||
const result = isPartnerSignupQuery( undefined ); | ||
expect( result ).toBe( false ); | ||
} ); | ||
|
||
it( 'should return false when currentQuery is null', () => { | ||
const result = isPartnerSignupQuery( null ); | ||
expect( result ).toBe( false ); | ||
} ); | ||
|
||
it( 'should return true when currentQuery has is_partner_signup', () => { | ||
const currentQuery = { is_partner_signup: true }; | ||
const result = isPartnerSignupQuery( currentQuery ); | ||
expect( result ).toBe( true ); | ||
} ); | ||
|
||
it( 'should return true when currentQuery has redirect_to with partner-signup', () => { | ||
const currentQuery = { redirect_to: 'https://woocommerce.com/partner-signup' }; | ||
const result = isPartnerSignupQuery( currentQuery ); | ||
expect( result ).toBe( true ); | ||
} ); | ||
|
||
it( 'should return true when currentQuery has oauth2_redirect with partner-signup', () => { | ||
const currentQuery = { oauth2_redirect: 'https://woocommerce.com/partner-signup' }; | ||
const result = isPartnerSignupQuery( currentQuery ); | ||
expect( result ).toBe( true ); | ||
} ); | ||
|
||
it( 'should throw an error when an unexpected error occurs', () => { | ||
const currentQuery = { redirect_to: 'https://woocommerce.com/partner-signup' }; | ||
const originalDecodeURIComponent = global.decodeURIComponent; | ||
global.decodeURIComponent = jest.fn( () => { | ||
throw new Error( 'Unexpected error' ); | ||
} ); | ||
|
||
expect( () => isPartnerSignupQuery( currentQuery ) ).toThrow( 'Unexpected error' ); | ||
|
||
// Restore the original decodeURIComponent function | ||
global.decodeURIComponent = originalDecodeURIComponent; | ||
} ); | ||
} ); |
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