1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
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
expect(wrapper.find('div[day="0"] li[task-id="pwen8kz22g.ics"]').exists()).toBe(true) // Was due today --> shown
expect(wrapper.find('div[day="0"] li[task-id="pwen7kz22g.ics"]').exists()).toBe(false) // Subtask due in 2 days--> 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
expect(wrapper.find('div[day="2"] li[task-id="pwen8kz22g.ics"]').exists()).toBe(true) // Was due today, but has subtask due in 2 days --> shown
expect(wrapper.find('div[day="2"] li[task-id="pwen7kz22g.ics"]').exists()).toBe(true) // Subtask due in 2 days--> shown
expect(wrapper.find('div[day="2"] li[task-id="pwen2kz37g.ics"]').exists()).toBe(false) // Subtask due in a month --> hidden
})
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
})
it('Checks that only the clicked task is marked active', () => {
const wrapper = mount(Week, { localVue, store, router })
let taskAtDay0 = wrapper.find('div[day="0"] li[task-id="pwen8kz22g.ics"] > div')
let taskAtDay2 = wrapper.find('div[day="2"] li[task-id="pwen8kz22g.ics"] > div')
// Click on first task to open it
taskAtDay0.trigger('click')
expect(taskAtDay0.classes('active')).toBe(true) // Should be shown active, since it was clicked
expect(taskAtDay2.classes('active')).toBe(false) // Shouldn't be shown active, since it was not clicked
})
it('Checks that not matching subtasks are only shown for active tasks', () => {
const wrapper = mount(Week, { localVue, store, router })
let taskAtDay0 = wrapper.find('div[day="0"] li[task-id="pwen8kz22g.ics"] > div')
if (wrapper.vm.$route.params.taskId !== null) {
router.push({ name: 'collections', params: { collectionId: 'week' } })
}
expect(taskAtDay0.classes('active')).toBe(false)
expect(wrapper.find('div[day="0"] li[task-id="pwen7kz22g.ics"]').exists()).toBe(false) // Not shown, since it doesn't match collection
expect(wrapper.find('div[day="0"] li[task-id="pwen2kz37g.ics"]').exists()).toBe(false) // Not shown, since it doesn't match collection
expect(wrapper.find('div[day="2"] li[task-id="pwen7kz22g.ics"]').exists()).toBe(true) // Shown, since it is due in 2 days
// Click on first task to open it
taskAtDay0.trigger('click')
expect(taskAtDay0.classes('active')).toBe(true)
expect(wrapper.find('div[day="0"] li[task-id="pwen7kz22g.ics"]').exists()).toBe(true) // Shown now, because parent is active
expect(wrapper.find('div[day="0"] li[task-id="pwen2kz37g.ics"]').exists()).toBe(true) // Shown now, because parent is active
expect(wrapper.find('div[day="2"] li[task-id="pwen2kz37g.ics"]').exists()).toBe(false) // Not shown, since parent is not active
})
})
|