diff --git a/test/views/statuses/index.test.js b/test/views/statuses/index.test.js index d83c4960..e6173883 100644 --- a/test/views/statuses/index.test.js +++ b/test/views/statuses/index.test.js @@ -58,4 +58,46 @@ describe('Statuses', () => { expect(store.state.status.fetchedStatuses.length).toEqual(2) done() }) + + it('handles status select', async (done) => { + const wrapper = mount(Statuses, { + store: store, + localVue + }) + await flushPromises() + + store.dispatch('HandleFilterChange', 'heaven.com') + wrapper.vm.handleFilterChange() + await flushPromises() + wrapper.find('.status-checkbox input').setChecked() + await flushPromises() + + expect(wrapper.vm.selectedUsers.length).toEqual(1) + expect(wrapper.vm.selectedUsers[0].display_name).toBe('sky') + done() + }) + + it('clear state after component was destroyed', async (done) => { + const wrapper = mount(Statuses, { + store: store, + localVue + }) + await flushPromises() + + store.dispatch('HandleFilterChange', 'heaven.com') + wrapper.vm.handleFilterChange() + await flushPromises() + wrapper.find('.status-checkbox input').setChecked() + await flushPromises() + + expect(wrapper.vm.selectedUsers.length).toEqual(1) + expect(store.state.status.statusesByInstance.selectedInstance).toBe('heaven.com') + expect(store.state.status.fetchedStatuses.length).toEqual(2) + wrapper.destroy() + + expect(wrapper.vm.selectedUsers.length).toEqual(0) + expect(store.state.status.statusesByInstance.selectedInstance).toBe('') + expect(store.state.status.fetchedStatuses.length).toEqual(0) + done() + }) })