From a9b82b331b9547e7e5b1c862fc6c490d71972d51 Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Sat, 16 Feb 2019 18:54:02 +0900
Subject: [PATCH 1/2] refs #209 Add integration tests for Jump modal
---
.../store/TimelineSpace/Modals/Jump.spec.js | 101 ++++++++++++++++++
1 file changed, 101 insertions(+)
create mode 100644 spec/integration/store/TimelineSpace/Modals/Jump.spec.js
diff --git a/spec/integration/store/TimelineSpace/Modals/Jump.spec.js b/spec/integration/store/TimelineSpace/Modals/Jump.spec.js
new file mode 100644
index 00000000..1ecf5722
--- /dev/null
+++ b/spec/integration/store/TimelineSpace/Modals/Jump.spec.js
@@ -0,0 +1,101 @@
+import { createLocalVue } from '@vue/test-utils'
+import Vuex from 'vuex'
+import i18n from '~/src/config/i18n'
+import router from '@/router'
+import Jump from '~/src/renderer/store/TimelineSpace/Modals/Jump'
+
+const state = {
+ modalOpen: true,
+ channel: '',
+ defaultChannelList: [
+ {
+ name: i18n.t('side_menu.home'),
+ path: 'home'
+ },
+ {
+ name: i18n.t('side_menu.notification'),
+ path: 'notifications'
+ },
+ {
+ name: i18n.t('side_menu.favourite'),
+ path: 'favourites'
+ },
+ {
+ name: i18n.t('side_menu.local'),
+ path: 'local'
+ },
+ {
+ name: i18n.t('side_menu.public'),
+ path: 'public'
+ },
+ {
+ name: i18n.t('side_menu.hashtag'),
+ path: 'hashtag'
+ },
+ {
+ name: i18n.t('side_menu.search'),
+ path: 'search'
+ },
+ {
+ name: i18n.t('side_menu.direct'),
+ path: 'direct-messages'
+ }
+ ],
+ listChannelList: [],
+ tagChannelList: [],
+ selectedChannel: {
+ name: i18n.t('side_menu.home'),
+ path: 'home'
+ }
+}
+
+const initState = {
+ namespaced: true,
+ state: state,
+ actions: Jump.actions,
+ mutations: Jump.mutations
+}
+
+const timelineState = {
+ namespaced: true,
+ state: {
+ account: {
+ _id: '0'
+ }
+ }
+}
+
+describe('Jump', () => {
+ let store
+ let localVue
+
+ beforeEach(() => {
+ localVue = createLocalVue()
+ localVue.use(Vuex)
+ store = new Vuex.Store({
+ modules: {
+ Jump: initState,
+ TimelineSpace: timelineState
+ }
+ })
+ })
+
+ describe('jumpCurrentSelected', () => {
+ it('should be changed', () => {
+ store.dispatch('Jump/jumpCurrentSelected')
+ expect(store.state.Jump.modalOpen).toEqual(false)
+ expect(router.push).toHaveBeenCalledWith({ path: '/0/home' })
+ })
+ })
+
+ describe('jump', () => {
+ it('should be changed', () => {
+ store.dispatch('Jump/jump', {
+ name: 'public',
+ path: 'public'
+ })
+ expect(store.state.Jump.modalOpen).toEqual(false)
+ expect(router.push).toHaveBeenCalledWith({ path: '/0/public' })
+ })
+ })
+})
From d3574a4619b8e40417aab83d62086c861fadb08a Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Sat, 16 Feb 2019 19:04:55 +0900
Subject: [PATCH 2/2] refs #209 Add unit tests for Jump modal
---
.../store/TimelineSpace/Modals/Jump.spec.js | 112 ++++++++++++++++++
1 file changed, 112 insertions(+)
create mode 100644 spec/unit/store/TimelineSpace/Modals/Jump.spec.js
diff --git a/spec/unit/store/TimelineSpace/Modals/Jump.spec.js b/spec/unit/store/TimelineSpace/Modals/Jump.spec.js
new file mode 100644
index 00000000..17b4a87b
--- /dev/null
+++ b/spec/unit/store/TimelineSpace/Modals/Jump.spec.js
@@ -0,0 +1,112 @@
+import i18n from '~/src/config/i18n'
+import Jump from '@/store/TimelineSpace/Modals/Jump'
+
+describe('TimelineSpace/Modals/Jump', () => {
+ describe('mutations', () => {
+ let state
+ beforeEach(() => {
+ state = {
+ modalOpen: true,
+ channel: '',
+ defaultChannelList: [
+ {
+ name: i18n.t('side_menu.home'),
+ path: 'home'
+ },
+ {
+ name: i18n.t('side_menu.notification'),
+ path: 'notifications'
+ },
+ {
+ name: i18n.t('side_menu.favourite'),
+ path: 'favourites'
+ },
+ {
+ name: i18n.t('side_menu.local'),
+ path: 'local'
+ },
+ {
+ name: i18n.t('side_menu.public'),
+ path: 'public'
+ },
+ {
+ name: i18n.t('side_menu.hashtag'),
+ path: 'hashtag'
+ },
+ {
+ name: i18n.t('side_menu.search'),
+ path: 'search'
+ },
+ {
+ name: i18n.t('side_menu.direct'),
+ path: 'direct-messages'
+ }
+ ],
+ listChannelList: [],
+ tagChannelList: [],
+ selectedChannel: {
+ name: i18n.t('side_menu.home'),
+ path: 'home'
+ }
+ }
+ })
+
+ describe('updateListChannel', () => {
+ it('should be updated', () => {
+ const channelList = [
+ {
+ id: '0',
+ title: 'admin'
+ },
+ {
+ id: '1',
+ title: 'engineer'
+ },
+ {
+ id: '2',
+ title: 'designer'
+ }
+ ]
+ Jump.mutations.updateListChannel(state, channelList)
+ expect(state.listChannelList).toEqual([
+ {
+ path: 'lists/0',
+ name: '#admin'
+ },
+ {
+ path: 'lists/1',
+ name: '#engineer'
+ },
+ {
+ path: 'lists/2',
+ name: '#designer'
+ }
+ ])
+ })
+ })
+
+ describe('updateTagChannel', () => {
+ it('should be updated', () => {
+ const channelList = [
+ {
+ tagName: 'whalebird'
+ },
+ {
+ tagName: 'tqrk'
+ }
+ ]
+ Jump.mutations.updateTagChannel(state, channelList)
+ expect(state.tagChannelList).toEqual([
+ {
+ name: '#whalebird',
+ path: 'hashtag/whalebird'
+ },
+ {
+ name: '#tqrk',
+ path: 'hashtag/tqrk'
+ }
+ ])
+ })
+ })
+ })
+})