mirror of
https://github.com/h3poteto/whalebird-desktop
synced 2024-12-28 09:41:09 +01:00
refs #209 Add integration tests for Hashtag/List
This commit is contained in:
parent
ceefd69b26
commit
c89ac69056
@ -0,0 +1,68 @@
|
||||
import { Event } from 'electron'
|
||||
import { createLocalVue } from '@vue/test-utils'
|
||||
import { ipcMain } from '~/spec/mock/electron'
|
||||
import Vuex from 'vuex'
|
||||
import { LocalTag } from '~/src/types/localTag'
|
||||
import List, { ListState } from '@/store/TimelineSpace/Contents/Hashtag/List'
|
||||
|
||||
const tag1: LocalTag = {
|
||||
tagName: 'tag1',
|
||||
_id: '1'
|
||||
}
|
||||
|
||||
const tag2: LocalTag = {
|
||||
tagName: 'tag2',
|
||||
_id: '2'
|
||||
}
|
||||
|
||||
const state = (): ListState => {
|
||||
return {
|
||||
tags: []
|
||||
}
|
||||
}
|
||||
|
||||
const initStore = () => {
|
||||
return {
|
||||
namespaced: true,
|
||||
state: state(),
|
||||
actions: List.actions,
|
||||
mutations: List.mutations
|
||||
}
|
||||
}
|
||||
|
||||
describe('Hashtag/List', () => {
|
||||
let store
|
||||
let localVue
|
||||
|
||||
beforeEach(() => {
|
||||
localVue = createLocalVue()
|
||||
localVue.use(Vuex)
|
||||
store = new Vuex.Store({
|
||||
modules: {
|
||||
List: initStore()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
describe('listTags', () => {
|
||||
it('should be updated', async () => {
|
||||
ipcMain.once('list-hashtags', (event: Event) => {
|
||||
event.sender.send('response-list-hashtags', [tag1, tag2])
|
||||
})
|
||||
await store.dispatch('List/listTags')
|
||||
expect(store.state.List.tags).toEqual([tag1, tag2])
|
||||
})
|
||||
})
|
||||
|
||||
describe('removeTag', () => {
|
||||
it('should be updated', async () => {
|
||||
ipcMain.once('remove-hashtag', async () => {
|
||||
ipcMain.once('remove-hashtag', (event: Event, tag: LocalTag) => {
|
||||
expect(tag).toEqual(tag1)
|
||||
event.sender.send('response-remove-hashtag')
|
||||
})
|
||||
await store.dispatch('List/removeTag', tag1)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue
Block a user