diff options
Diffstat (limited to 'spec/frontend/notes/components/sort_discussion_spec.js')
-rw-r--r-- | spec/frontend/notes/components/sort_discussion_spec.js | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/spec/frontend/notes/components/sort_discussion_spec.js b/spec/frontend/notes/components/sort_discussion_spec.js index 575f1057db2..739e247735d 100644 --- a/spec/frontend/notes/components/sort_discussion_spec.js +++ b/spec/frontend/notes/components/sort_discussion_spec.js @@ -46,7 +46,7 @@ describe('Sort Discussion component', () => { it('calls setDiscussionSortDirection when update is emitted', () => { findLocalStorageSync().vm.$emit('input', ASC); - expect(store.dispatch).toHaveBeenCalledWith('setDiscussionSortDirection', ASC); + expect(store.dispatch).toHaveBeenCalledWith('setDiscussionSortDirection', { direction: ASC }); }); }); @@ -55,9 +55,11 @@ describe('Sort Discussion component', () => { it('calls the right actions', () => { createComponent(); - wrapper.find('.js-newest-first').trigger('click'); + wrapper.find('.js-newest-first').vm.$emit('click'); - expect(store.dispatch).toHaveBeenCalledWith('setDiscussionSortDirection', DESC); + expect(store.dispatch).toHaveBeenCalledWith('setDiscussionSortDirection', { + direction: DESC, + }); expect(Tracking.event).toHaveBeenCalledWith(undefined, 'change_discussion_sort_direction', { property: DESC, }); @@ -67,7 +69,7 @@ describe('Sort Discussion component', () => { it('shows the "Oldest First" as the dropdown', () => { createComponent(); - expect(wrapper.find('.js-dropdown-text').text()).toBe('Oldest first'); + expect(wrapper.find('.js-dropdown-text').props('text')).toBe('Oldest first'); }); }); @@ -79,21 +81,23 @@ describe('Sort Discussion component', () => { describe('when the dropdown item is clicked', () => { it('calls the right actions', () => { - wrapper.find('.js-oldest-first').trigger('click'); + wrapper.find('.js-oldest-first').vm.$emit('click'); - expect(store.dispatch).toHaveBeenCalledWith('setDiscussionSortDirection', ASC); + expect(store.dispatch).toHaveBeenCalledWith('setDiscussionSortDirection', { + direction: ASC, + }); expect(Tracking.event).toHaveBeenCalledWith(undefined, 'change_discussion_sort_direction', { property: ASC, }); }); - it('applies the active class to the correct button in the dropdown', () => { - expect(wrapper.find('.js-newest-first').classes()).toContain('is-active'); + it('sets is-checked to true on the active button in the dropdown', () => { + expect(wrapper.find('.js-newest-first').props('isChecked')).toBe(true); }); }); it('shows the "Newest First" as the dropdown', () => { - expect(wrapper.find('.js-dropdown-text').text()).toBe('Newest first'); + expect(wrapper.find('.js-dropdown-text').props('text')).toBe('Newest first'); }); }); }); |