-
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.
Merge pull request #11606 from Automattic/fix/comment-link-on-streams
Accept comments argument in showSelectedPost
- Loading branch information
Showing
3 changed files
with
55 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import sinon from 'sinon'; | ||
import { expect } from 'chai'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import useFakeDom from 'test/helpers/use-fake-dom'; | ||
import useMockery from 'test/helpers/use-mockery'; | ||
|
||
describe( 'reader utils', () => { | ||
const pageSpy = sinon.spy(); | ||
|
||
beforeEach( () => { | ||
pageSpy.reset(); | ||
} ); | ||
|
||
describe( '#showSelectedPost', () => { | ||
let showSelectedPost; | ||
useFakeDom(); | ||
useMockery( ( mockery ) => { | ||
mockery.registerMock( 'page', { | ||
show: pageSpy, | ||
} ); | ||
mockery.registerMock( 'lib/feed-stream-store/actions', { | ||
selectItem: sinon.stub(), | ||
} ); | ||
mockery.registerMock( 'reader/controller-helper', { | ||
setLastStoreId: sinon.stub(), | ||
} ); | ||
showSelectedPost = require( '../utils' ).showSelectedPost; | ||
} ); | ||
|
||
it( 'does not do anything if postKey argument is missing', () => { | ||
showSelectedPost( {} ); | ||
expect( pageSpy ).to.have.not.been.called; | ||
} ); | ||
|
||
it( 'redirects if passed a post key', () => { | ||
showSelectedPost( { postKey: { feedId: 1, postId: 5 } } ); | ||
expect( pageSpy ).to.have.been.calledOnce; | ||
} ); | ||
|
||
it( 'redirects to a #comments URL if we passed comments argument', () => { | ||
showSelectedPost( { postKey: { feedId: 1, postId: 5 }, comments: true } ); | ||
expect( pageSpy ).to.have.been.calledWithMatch('#comments'); | ||
} ); | ||
} ); | ||
} ); |
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