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:40:54 +0300
committerRaimund Schlüßler <raimund.schluessler@mailbox.org>2019-10-29 23:40:54 +0300
commit0c86fe6a506df68e504c628d430ad5a0e242891a (patch)
treeacf15cf1ee77323279b5d34771d6a5c4ee4ad35d /tests
parentbefa3782aab3c66c6a8a177380c50395dd1df79d (diff)
Add tests for current, today and completed collection
Signed-off-by: Raimund Schlüßler <raimund.schluessler@mailbox.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/javascript/unit/components/TheCollections/General.spec.js24
-rw-r--r--tests/javascript/unit/setup.js10
-rw-r--r--tests/javascript/unit/store/storeHelper.spec.js8
3 files changed, 34 insertions, 8 deletions
diff --git a/tests/javascript/unit/components/TheCollections/General.spec.js b/tests/javascript/unit/components/TheCollections/General.spec.js
index 890f4525..b892a434 100644
--- a/tests/javascript/unit/components/TheCollections/General.spec.js
+++ b/tests/javascript/unit/components/TheCollections/General.spec.js
@@ -25,4 +25,28 @@ describe('General.vue', () => {
}
expect(wrapper.vm.filteredCalendars.length).toBe(1)
})
+
+ it('Checks that we get the correct number of calendars for the current view', () => {
+ const wrapper = mount(General, { localVue, store, router })
+ if (wrapper.vm.$route.params.collectionId !== 'current') {
+ router.push({ name: 'collections', params: { collectionId: 'current' } })
+ }
+ expect(wrapper.vm.filteredCalendars.length).toBe(2)
+ })
+
+ it('Checks that we get the correct number of calendars for the today view', () => {
+ const wrapper = mount(General, { localVue, store, router })
+ if (wrapper.vm.$route.params.collectionId !== 'today') {
+ router.push({ name: 'collections', params: { collectionId: 'today' } })
+ }
+ expect(wrapper.vm.filteredCalendars.length).toBe(0)
+ })
+
+ it('Checks that we get the correct number of calendars for the completed view', () => {
+ const wrapper = mount(General, { localVue, store, router })
+ if (wrapper.vm.$route.params.collectionId !== 'completed') {
+ router.push({ name: 'collections', params: { collectionId: 'completed' } })
+ }
+ expect(wrapper.vm.filteredCalendars.length).toBe(0)
+ })
})
diff --git a/tests/javascript/unit/setup.js b/tests/javascript/unit/setup.js
index fc581e20..6f72d3d1 100644
--- a/tests/javascript/unit/setup.js
+++ b/tests/javascript/unit/setup.js
@@ -1,7 +1,13 @@
import VueTestUtils from '@vue/test-utils'
import { OC } from './OC.js'
+import moment from 'moment'
+import MockDate from 'mockdate'
+
+// Set date to fixed value
+MockDate.set(moment('20190101T123456', 'YYYYMMDDTHHmmss'))
global.OC = new OC()
+global.moment = moment
// Mock nextcloud translate functions
VueTestUtils.config.mocks.$t = function(app, string) {
@@ -15,3 +21,7 @@ VueTestUtils.config.mocks.$n = function(app, singular, plural, count) {
}
VueTestUtils.config.mocks.n = VueTestUtils.config.mocks.$n
global.n = VueTestUtils.config.mocks.$n
+
+afterAll(() => {
+ MockDate.reset()
+});
diff --git a/tests/javascript/unit/store/storeHelper.spec.js b/tests/javascript/unit/store/storeHelper.spec.js
index 39c7a9f2..af0ccfdf 100644
--- a/tests/javascript/unit/store/storeHelper.spec.js
+++ b/tests/javascript/unit/store/storeHelper.spec.js
@@ -1,9 +1,5 @@
-import moment from 'moment'
-import MockDate from 'mockdate'
import { sort } from '../../../../src/store/storeHelper'
-global.moment = moment
-
const tasks = [
{
id: 1,
@@ -41,9 +37,5 @@ describe('storeHelper', () => {
})
it("Tests if correct tasks are found for the 'current' collection.", () => {
- // Set date to fixed value
- MockDate.set(moment('20190101T123456', 'YYYYMMDDTHHmmss'))
-
- MockDate.reset()
})
})