-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into enhancement/9570-skeleton-loader-wp-dashb…
…oard.
- Loading branch information
Showing
6 changed files
with
200 additions
and
32 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 |
---|---|---|
|
@@ -20,6 +20,8 @@ | |
* Internal dependencies | ||
*/ | ||
import API from 'googlesitekit-api'; | ||
import Modules from 'googlesitekit-modules'; | ||
import { combineStores } from 'googlesitekit-data'; | ||
import { | ||
createTestRegistry, | ||
muteFetch, | ||
|
@@ -2186,5 +2188,94 @@ describe( 'core/modules modules', () => { | |
await waitForDefaultTimeouts(); | ||
} ); | ||
} ); | ||
|
||
describe( 'getDetailsLinkURL', () => { | ||
it( 'should return null if module is not found', () => { | ||
registry.dispatch( CORE_MODULES ).receiveGetModules( FIXTURES ); | ||
|
||
expect( | ||
registry | ||
.select( CORE_MODULES ) | ||
.getDetailsLinkURL( 'unregistered-module' ) | ||
).toBeNull(); | ||
} ); | ||
|
||
it( 'should return null if module does not define homepage', () => { | ||
registry.dispatch( CORE_MODULES ).receiveGetModules( [ | ||
{ | ||
slug: 'search-console', | ||
name: 'Search Console', | ||
active: true, | ||
connected: true, | ||
}, | ||
] ); | ||
|
||
expect( | ||
registry | ||
.select( CORE_MODULES ) | ||
.getDetailsLinkURL( 'search-console' ) | ||
).toBeNull(); | ||
} ); | ||
|
||
it( 'should return module homepage', () => { | ||
registry.dispatch( CORE_MODULES ).receiveGetModules( [ | ||
{ | ||
slug: 'search-console', | ||
name: 'Search Console', | ||
homepage: 'https://example.com', | ||
active: true, | ||
connected: true, | ||
}, | ||
] ); | ||
registry | ||
.dispatch( CORE_USER ) | ||
.receiveUserInfo( { email: '[email protected]' } ); | ||
|
||
expect( | ||
registry | ||
.select( CORE_MODULES ) | ||
.getDetailsLinkURL( 'search-console' ) | ||
).toBe( | ||
'https://accounts.google.com/accountchooser?continue=https%3A%2F%2Fexample.com&Email=test%40example.com' | ||
); | ||
} ); | ||
|
||
it( 'should be overridden by module defined selector', () => { | ||
const slug = 'test-module'; | ||
const moduleStoreName = `test/${ slug }`; | ||
|
||
registry.registerStore( | ||
moduleStoreName, | ||
combineStores( | ||
Modules.createModuleStore( slug, { | ||
storeName: moduleStoreName, | ||
} ), | ||
{ | ||
selectors: { | ||
getDetailsLinkURL: () => | ||
'https://example.com/custom-link', | ||
}, | ||
} | ||
) | ||
); | ||
|
||
registry | ||
.dispatch( CORE_MODULES ) | ||
.registerModule( slug, { storeName: moduleStoreName } ); | ||
|
||
registry.dispatch( CORE_MODULES ).receiveGetModules( [ | ||
{ | ||
slug, | ||
name: 'Test Module', | ||
active: true, | ||
connected: true, | ||
}, | ||
] ); | ||
|
||
expect( | ||
registry.select( CORE_MODULES ).getDetailsLinkURL( slug ) | ||
).toBe( 'https://example.com/custom-link' ); | ||
} ); | ||
} ); | ||
} ); | ||
} ); |
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