Tests for handling status select and clearing the state after component was destroyed
This commit is contained in:
parent
cb99014af5
commit
008162c508
1 changed files with 42 additions and 0 deletions
|
@ -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()
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue