From 10e773a7a216f64149dd5e035aefb2b564c6b064 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raimund=20Schl=C3=BC=C3=9Fler?= Date: Thu, 7 Nov 2019 21:03:44 +0100 Subject: [PATCH] Add simple test for week view MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Raimund Schlüßler --- src/components/TheCollections/Week.vue | 4 ++- .../components/TheCollections/Week.spec.js | 35 +++++++++++++++++++ tests/javascript/unit/setupStore.js | 18 +++++++++- 3 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 tests/javascript/unit/components/TheCollections/Week.spec.js diff --git a/src/components/TheCollections/Week.vue b/src/components/TheCollections/Week.vue index 768a4fff..5e8e4164 100644 --- a/src/components/TheCollections/Week.vue +++ b/src/components/TheCollections/Week.vue @@ -24,7 +24,9 @@ License along with this library. If not, see .
-
+

{{ day.diff | formatDay }}

diff --git a/tests/javascript/unit/components/TheCollections/Week.spec.js b/tests/javascript/unit/components/TheCollections/Week.spec.js new file mode 100644 index 00000000..53110773 --- /dev/null +++ b/tests/javascript/unit/components/TheCollections/Week.spec.js @@ -0,0 +1,35 @@ +import { mount } from '@vue/test-utils' +import Week from '../../../../../src/components/TheCollections/Week' +import router from '../../../../../src/components/TheRouter' + +import { store, localVue } from '../../setupStore' + +import VTooltip from 'v-tooltip' +localVue.use(VTooltip) + +describe('Week.vue', () => { + 'use strict' + + it('Checks that the correct tasks are shown for day 0 (today)', () => { + const wrapper = mount(Week, { localVue, store, router }) + expect(wrapper.find('div[day="0"] li[task-id="pwen4kz18g.ics"]').exists()).toBe(true) // Was due today --> shown + expect(wrapper.find('div[day="0"] li[task-id="pwen4kz20g.ics"]').exists()).toBe(true) // Has a due subtask --> shown + expect(wrapper.find('div[day="0"] li[task-id="pwen4kz23g.ics"]').exists()).toBe(true) // Due subtask --> shown + expect(wrapper.find('div[day="0"] li[task-id="pwen4kz25g.ics"]').exists()).toBe(false) // Start date in future --> hidden + }) + + it('Checks that the correct tasks are shown for day 1 (tomorrow)', () => { + const wrapper = mount(Week, { localVue, store, router }) + expect(wrapper.find('div[day="1"] li[task-id="pwen4kz41g.ics"]').exists()).toBe(true) // Starts tomorrow --> shown + }) + + it('Checks that the correct tasks are shown for day 2 (day after tomorrow)', () => { + const wrapper = mount(Week, { localVue, store, router }) + expect(wrapper.find('div[day="2"] li[task-id="pwen4kz21g.ics"]').exists()).toBe(true) // Start the day after tomorrow --> shown + }) + + it('Checks that the correct tasks are shown for day 6', () => { + const wrapper = mount(Week, { localVue, store, router }) + expect(wrapper.find('div[day="6"] li[task-id="pwen4kz22g.ics"]').exists()).toBe(true) // Starts in 7 days --> shown + }) +}) diff --git a/tests/javascript/unit/setupStore.js b/tests/javascript/unit/setupStore.js index 9d398285..fa6d71dd 100644 --- a/tests/javascript/unit/setupStore.js +++ b/tests/javascript/unit/setupStore.js @@ -150,13 +150,27 @@ CREATED:20181119T183919\n DTSTAMP:20190918T095816\n LAST-MODIFIED:20190918T095816\n UID:pwen4kz40g\n -SUMMARY:Calendar 1 - Task 2\n +SUMMARY:Calendar 1 - Task 5\n PRIORITY:9\n PERCENT-COMPLETE:100\n STATUS:COMPLETED\n COMPLETED:20190918T095816\n DTSTART:20190918T095816\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:pwen4kz41g\n +SUMMARY:Calendar 1 - Task 6\n +PRIORITY:9\n +DTSTART:20190102T095816\n +END:VTODO\n END:VCALENDAR` ], }, @@ -177,6 +191,7 @@ DTSTAMP:20190918T095816\n LAST-MODIFIED:20190918T095816\n UID:pwen4kz21g\n SUMMARY:Calendar 2 - Task 1\n +DUE:20190103T120000\n END:VTODO\n END:VCALENDAR`, ` @@ -189,6 +204,7 @@ DTSTAMP:20190918T095816\n LAST-MODIFIED:20190918T095816\n UID:pwen4kz22g\n SUMMARY:Calendar 2 - Task 2\n +DUE:20190107T120000\n END:VTODO\n END:VCALENDAR` ],