diff --git a/spec/renderer/integration/store/TimelineSpace/Contents/Hashtag/List.spec.ts b/spec/renderer/integration/store/TimelineSpace/Contents/Hashtag/List.spec.ts new file mode 100644 index 00000000..1505b054 --- /dev/null +++ b/spec/renderer/integration/store/TimelineSpace/Contents/Hashtag/List.spec.ts @@ -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) + }) + }) + }) +})