2020-03-13 15:44:24 +05:30
import { shallowMount } from '@vue/test-utils' ;
2021-01-29 00:20:46 +05:30
import { GlButton , GlSprintf } from '@gitlab/ui' ;
2020-03-13 15:44:24 +05:30
import DiscussionFilterNote from '~/notes/components/discussion_filter_note.vue' ;
import eventHub from '~/notes/event_hub' ;
describe ( 'DiscussionFilterNote component' , ( ) => {
let wrapper ;
const createComponent = ( ) => {
2021-01-29 00:20:46 +05:30
wrapper = shallowMount ( DiscussionFilterNote , {
stubs : {
GlSprintf ,
} ,
} ) ;
2020-03-13 15:44:24 +05:30
} ;
beforeEach ( ( ) => {
createComponent ( ) ;
} ) ;
afterEach ( ( ) => {
wrapper . destroy ( ) ;
wrapper = null ;
} ) ;
it ( 'timelineContent renders a string containing instruction for switching feed type' , ( ) => {
2021-01-29 00:20:46 +05:30
expect ( wrapper . find ( '[data-testid="discussion-filter-timeline-content"]' ) . html ( ) ) . toBe (
'<div data-testid="discussion-filter-timeline-content">You\'re only seeing <b>other activity</b> in the feed. To add a comment, switch to one of the following options.</div>' ,
2020-03-13 15:44:24 +05:30
) ;
} ) ;
it ( 'emits `dropdownSelect` event with 0 parameter on clicking Show all activity button' , ( ) => {
jest . spyOn ( eventHub , '$emit' ) . mockImplementation ( ( ) => { } ) ;
2021-01-29 00:20:46 +05:30
wrapper
. findAll ( GlButton )
. at ( 0 )
. vm . $emit ( 'click' ) ;
2020-03-13 15:44:24 +05:30
expect ( eventHub . $emit ) . toHaveBeenCalledWith ( 'dropdownSelect' , 0 ) ;
} ) ;
it ( 'emits `dropdownSelect` event with 1 parameter on clicking Show comments only button' , ( ) => {
jest . spyOn ( eventHub , '$emit' ) . mockImplementation ( ( ) => { } ) ;
2021-01-29 00:20:46 +05:30
wrapper
. findAll ( GlButton )
. at ( 1 )
. vm . $emit ( 'click' ) ;
2020-03-13 15:44:24 +05:30
expect ( eventHub . $emit ) . toHaveBeenCalledWith ( 'dropdownSelect' , 1 ) ;
} ) ;
} ) ;