Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/tasks.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRaimund Schlüßler <raimund.schluessler@mailbox.org>2019-10-29 23:15:25 +0300
committerRaimund Schlüßler <raimund.schluessler@mailbox.org>2019-10-29 23:15:25 +0300
commitbefa3782aab3c66c6a8a177380c50395dd1df79d (patch)
treecf2407e1757e6d4d34340e80a82d507defa5c679 /tests
parent899c2c9af1449b065a569ea6efec26e73aaa8f29 (diff)
Move creating store into separate file
Signed-off-by: Raimund Schlüßler <raimund.schluessler@mailbox.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/javascript/unit/components/TheCollections/General.spec.js108
-rw-r--r--tests/javascript/unit/setupStore.js116
2 files changed, 124 insertions, 100 deletions
diff --git a/tests/javascript/unit/components/TheCollections/General.spec.js b/tests/javascript/unit/components/TheCollections/General.spec.js
index 9096e2ed..890f4525 100644
--- a/tests/javascript/unit/components/TheCollections/General.spec.js
+++ b/tests/javascript/unit/components/TheCollections/General.spec.js
@@ -1,120 +1,28 @@
-import { mount, createLocalVue } from '@vue/test-utils'
+import { mount } from '@vue/test-utils'
import General from '../../../../../src/components/TheCollections/General'
-import store from '../../../../../src/store/store'
import router from '../../../../../src/components/TheRouter'
-import Task from '../../../../../src/models/task'
-import { mapDavCollectionToCalendar } from '../../../../../src/store/calendars'
+import { store, localVue } from '../../setupStore'
import VTooltip from 'v-tooltip'
-
-const localVue = createLocalVue()
localVue.use(VTooltip)
describe('General.vue', () => {
'use strict'
- const calendarsData = [
- {
- url: 'calendar-1/tmp',
- displayname: 'Calendar 1',
- color: '#123456',
- isWriteable: () => { return true },
- shares: [],
- components: ['VTODO'],
- tasks: [`
-BEGIN:VCALENDAR\n
-VERSION:2.0\n
-PRODID:-//Nextcloud Tasks 0.11.3\n
-BEGIN:VTODO\n
-CREATED:20181119T183919\n
-DTSTAMP:20190918T095816\n
-LAST-MODIFIED:20190918T095816\n
-UID:pwen4kz18g\n
-SUMMARY:Calendar 1 - Task 1\n
-PRIORITY:1\n
-END:VTODO\n
-END:VCALENDAR`,
-`
-BEGIN:VCALENDAR\n
-VERSION:2.0\n
-PRODID:-//Nextcloud Tasks 0.11.3\n
-BEGIN:VTODO\n
-CREATED:20181119T183919\n
-DTSTAMP:20190918T095816\n
-LAST-MODIFIED:20190918T095816\n
-UID:pwen4kz19g\n
-SUMMARY:Calendar 1 - Task 2\n
-PRIORITY:9\n
-END:VTODO\n
-END:VCALENDAR`,
-`
-BEGIN:VCALENDAR\n
-VERSION:2.0\n
-PRODID:-//Nextcloud Tasks 0.11.3\n
-BEGIN:VTODO\n
-CREATED:20181119T183919\n
-DTSTAMP:20190918T095816\n
-LAST-MODIFIED:20190918T095816\n
-UID:pwen4kz20g\n
-SUMMARY:Calendar 1 - Task 3\n
-END:VTODO\n
-END:VCALENDAR`
- ],
- },
- {
- url: 'calendar-2/tmp',
- displayname: 'Calendar 2',
- color: '#123456',
- isWriteable: () => { return true },
- shares: [],
- components: ['VTODO', 'VEVENT'],
- tasks: [`
-BEGIN:VCALENDAR\n
-VERSION:2.0\n
-PRODID:-//Nextcloud Tasks 0.11.3\n
-BEGIN:VTODO\n
-CREATED:20181119T183919\n
-DTSTAMP:20190918T095816\n
-LAST-MODIFIED:20190918T095816\n
-UID:pwen4kz21g\n
-SUMMARY:Calendar 2 - Task 1\n
-END:VTODO\n
-END:VCALENDAR`,
-`
-BEGIN:VCALENDAR\n
-VERSION:2.0\n
-PRODID:-//Nextcloud Tasks 0.11.3\n
-BEGIN:VTODO\n
-CREATED:20181119T183919\n
-DTSTAMP:20190918T095816\n
-LAST-MODIFIED:20190918T095816\n
-UID:pwen4kz22g\n
-SUMMARY:Calendar 2 - Task 2\n
-END:VTODO\n
-END:VCALENDAR`
- ],
- },
- ]
-
- calendarsData.forEach(calendarData => {
- const calendar = mapDavCollectionToCalendar(calendarData)
- const tasks = calendarData.tasks.map(taskData => {
- return new Task(taskData, calendar)
- })
- store.commit('addCalendar', calendar)
- store.commit('appendTasksToCalendar', { calendar, tasks })
- })
-
it('Checks that we get the correct number of calendars for the all view', () => {
const wrapper = mount(General, { localVue, store, router })
- router.push({ name: 'collections', params: { collectionId: 'all' } })
+ if (wrapper.vm.$route.params.collectionId !== 'all') {
+ router.push({ name: 'collections', params: { collectionId: 'all' } })
+ }
expect(wrapper.vm.calendars.length).toBe(2)
})
it('Checks that we get the correct number of calendars for the starred view', () => {
const wrapper = mount(General, { localVue, store, router })
- router.push({ name: 'collections', params: { collectionId: 'starred' } })
+ if (wrapper.vm.$route.params.collectionId !== 'starred') {
+ router.push({ name: 'collections', params: { collectionId: 'starred' } })
+ }
expect(wrapper.vm.filteredCalendars.length).toBe(1)
})
})
diff --git a/tests/javascript/unit/setupStore.js b/tests/javascript/unit/setupStore.js
new file mode 100644
index 00000000..c5049cb0
--- /dev/null
+++ b/tests/javascript/unit/setupStore.js
@@ -0,0 +1,116 @@
+import { createLocalVue } from '@vue/test-utils'
+import Vuex from 'vuex'
+
+import calendars from '../../../src/store/calendars'
+import collections from '../../../src/store/collections'
+import tasks from '../../../src/store/tasks'
+import settings from '../../../src/store/settings'
+import Task from '../../../src/models/task'
+
+import { mapDavCollectionToCalendar } from '../../../src/store/calendars'
+
+const localVue = createLocalVue()
+localVue.use(Vuex)
+
+const store = new Vuex.Store({
+ modules: {
+ calendars,
+ collections,
+ tasks,
+ settings
+ }
+})
+
+const calendarsData = [
+ {
+ url: 'calendar-1/tmp',
+ displayname: 'Calendar 1',
+ color: '#123456',
+ isWriteable: () => { return true },
+ shares: [],
+ components: ['VTODO'],
+ tasks: [`
+BEGIN:VCALENDAR\n
+VERSION:2.0\n
+PRODID:-//Nextcloud Tasks 0.11.3\n
+BEGIN:VTODO\n
+CREATED:20181119T183919\n
+DTSTAMP:20190918T095816\n
+LAST-MODIFIED:20190918T095816\n
+UID:pwen4kz18g\n
+SUMMARY:Calendar 1 - Task 1\n
+PRIORITY:1\n
+END:VTODO\n
+END:VCALENDAR`,
+`
+BEGIN:VCALENDAR\n
+VERSION:2.0\n
+PRODID:-//Nextcloud Tasks 0.11.3\n
+BEGIN:VTODO\n
+CREATED:20181119T183919\n
+DTSTAMP:20190918T095816\n
+LAST-MODIFIED:20190918T095816\n
+UID:pwen4kz19g\n
+SUMMARY:Calendar 1 - Task 2\n
+PRIORITY:9\n
+END:VTODO\n
+END:VCALENDAR`,
+`
+BEGIN:VCALENDAR\n
+VERSION:2.0\n
+PRODID:-//Nextcloud Tasks 0.11.3\n
+BEGIN:VTODO\n
+CREATED:20181119T183919\n
+DTSTAMP:20190918T095816\n
+LAST-MODIFIED:20190918T095816\n
+UID:pwen4kz20g\n
+SUMMARY:Calendar 1 - Task 3\n
+END:VTODO\n
+END:VCALENDAR`
+ ],
+ },
+ {
+ url: 'calendar-2/tmp',
+ displayname: 'Calendar 2',
+ color: '#123456',
+ isWriteable: () => { return true },
+ shares: [],
+ components: ['VTODO', 'VEVENT'],
+ tasks: [`
+BEGIN:VCALENDAR\n
+VERSION:2.0\n
+PRODID:-//Nextcloud Tasks 0.11.3\n
+BEGIN:VTODO\n
+CREATED:20181119T183919\n
+DTSTAMP:20190918T095816\n
+LAST-MODIFIED:20190918T095816\n
+UID:pwen4kz21g\n
+SUMMARY:Calendar 2 - Task 1\n
+END:VTODO\n
+END:VCALENDAR`,
+`
+BEGIN:VCALENDAR\n
+VERSION:2.0\n
+PRODID:-//Nextcloud Tasks 0.11.3\n
+BEGIN:VTODO\n
+CREATED:20181119T183919\n
+DTSTAMP:20190918T095816\n
+LAST-MODIFIED:20190918T095816\n
+UID:pwen4kz22g\n
+SUMMARY:Calendar 2 - Task 2\n
+END:VTODO\n
+END:VCALENDAR`
+ ],
+ },
+]
+
+calendarsData.forEach(calendarData => {
+ const calendar = mapDavCollectionToCalendar(calendarData)
+ const tasks = calendarData.tasks.map(taskData => {
+ return new Task(taskData, calendar)
+ })
+ store.commit('addCalendar', calendar)
+ store.commit('appendTasksToCalendar', { calendar, tasks })
+})
+
+export { store, localVue }