diff options
-rw-r--r-- | tests/javascript/unit/components/TheCollections/General.spec.js | 24 | ||||
-rw-r--r-- | tests/javascript/unit/setup.js | 10 | ||||
-rw-r--r-- | tests/javascript/unit/store/storeHelper.spec.js | 8 |
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() }) }) |