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

github.com/nextcloud/calendar.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2022-07-06 11:35:20 +0300
committerChristoph Wurst <christoph@winzerhof-wurst.at>2022-07-06 11:35:20 +0300
commitca2abbb2e82a753bcd6b5bbf34561b862819c955 (patch)
treeaec6e2b85b764bc26acb70e94e0b3c5af0043176 /tests
parent7582e1c75fd9e9fb5d0c1c2f457f01fa21c8d278 (diff)
Revert "Move event rendering to vue"
This reverts commit 5237a42fc1b95b43a717b07a2bed59d2c1c25651.
Diffstat (limited to 'tests')
-rw-r--r--tests/javascript/unit/fullcalendar/eventSources/freeBusyResourceEventSourceFunction.test.js148
-rw-r--r--tests/javascript/unit/fullcalendar/rendering/eventDidMount.test.js71
2 files changed, 139 insertions, 80 deletions
diff --git a/tests/javascript/unit/fullcalendar/eventSources/freeBusyResourceEventSourceFunction.test.js b/tests/javascript/unit/fullcalendar/eventSources/freeBusyResourceEventSourceFunction.test.js
index 99496570..9944827d 100644
--- a/tests/javascript/unit/fullcalendar/eventSources/freeBusyResourceEventSourceFunction.test.js
+++ b/tests/javascript/unit/fullcalendar/eventSources/freeBusyResourceEventSourceFunction.test.js
@@ -27,10 +27,10 @@ import {
getHexForColorName,
} from '../../../../../src/utils/color.js'
import { translate } from '@nextcloud/l10n'
-import { getAllObjectsInTimeRange } from '../../../../../src/utils/calendarObject.js'
+import {getAllObjectsInTimeRange} from "../../../../../src/utils/calendarObject.js";
jest.mock('@nextcloud/l10n')
jest.mock('../../../../../src/utils/color.js')
-jest.mock('../../../../../src/utils/calendarObject.js')
+jest.mock("../../../../../src/utils/calendarObject.js")
describe('fullcalendar/freeBusyResourceEventSourceFunction test suite', () => {
@@ -51,16 +51,16 @@ describe('fullcalendar/freeBusyResourceEventSourceFunction test suite', () => {
isLight
.mockImplementation(() => false)
- const event11Start = new Date(2020, 1, 1, 10, 0, 0, 0)
- const event11End = new Date(2020, 1, 1, 15, 0, 0, 0)
- const event12Start = new Date(2020, 1, 2, 10, 0, 0, 0)
- const event12End = new Date(2020, 1, 2, 15, 0, 0, 0)
- const event13Start = new Date(2020, 1, 3, 10, 0, 0, 0)
- const event13End = new Date(2020, 1, 3, 15, 0, 0, 0)
- const event21Start = new Date(2020, 5, 5, 0, 0, 0, 0)
- const event21End = new Date(2020, 5, 6, 0, 0, 0, 0)
- const event31Start = new Date(2020, 6, 10, 10, 0, 0, 0)
- const event31End = new Date(2020, 6, 10, 10, 0, 0, 0)
+ const event11Start = new Date(2020, 1, 1, 10, 0, 0, 0);
+ const event11End = new Date(2020, 1, 1, 15, 0, 0, 0);
+ const event12Start = new Date(2020, 1, 2, 10, 0, 0, 0);
+ const event12End = new Date(2020, 1, 2, 15, 0, 0, 0);
+ const event13Start = new Date(2020, 1, 3, 10, 0, 0, 0);
+ const event13End = new Date(2020, 1, 3, 15, 0, 0, 0);
+ const event21Start = new Date(2020, 5, 5, 0, 0, 0, 0);
+ const event21End = new Date(2020, 5, 6, 0, 0, 0, 0);
+ const event31Start = new Date(2020, 6, 10, 10, 0, 0, 0);
+ const event31End = new Date(2020, 6, 10, 10, 0, 0, 0);
const eventComponentSet1 = [{
name: 'VEVENT',
@@ -71,13 +71,13 @@ describe('fullcalendar/freeBusyResourceEventSourceFunction test suite', () => {
canModifyAllDay: jest.fn().mockReturnValue(false),
startDate: {
getInTimezone: jest.fn().mockReturnValue({
- jsDate: event11Start,
- }),
+ jsDate: event11Start
+ })
},
endDate: {
getInTimezone: jest.fn().mockReturnValue({
- jsDate: event11End,
- }),
+ jsDate: event11End
+ })
},
hasComponent: jest.fn().mockReturnValue(false),
}, {
@@ -89,13 +89,13 @@ describe('fullcalendar/freeBusyResourceEventSourceFunction test suite', () => {
canModifyAllDay: jest.fn().mockReturnValue(false),
startDate: {
getInTimezone: jest.fn().mockReturnValue({
- jsDate: event12Start,
- }),
+ jsDate: event12Start
+ })
},
endDate: {
getInTimezone: jest.fn().mockReturnValue({
- jsDate: event12End,
- }),
+ jsDate: event12End
+ })
},
hasComponent: jest.fn().mockReturnValue(false),
title: 'Untitled\nmultiline\nevent',
@@ -108,13 +108,13 @@ describe('fullcalendar/freeBusyResourceEventSourceFunction test suite', () => {
canModifyAllDay: jest.fn().mockReturnValue(false),
startDate: {
getInTimezone: jest.fn().mockReturnValue({
- jsDate: event13Start,
- }),
+ jsDate: event13Start
+ })
},
endDate: {
getInTimezone: jest.fn().mockReturnValue({
- jsDate: event13End,
- }),
+ jsDate: event13End
+ })
},
hasComponent: jest.fn().mockReturnValue(true),
}]
@@ -127,13 +127,13 @@ describe('fullcalendar/freeBusyResourceEventSourceFunction test suite', () => {
canModifyAllDay: jest.fn().mockReturnValue(true),
startDate: {
getInTimezone: jest.fn().mockReturnValue({
- jsDate: event21Start,
- }),
+ jsDate: event21Start
+ })
},
endDate: {
getInTimezone: jest.fn().mockReturnValue({
- jsDate: event21End,
- }),
+ jsDate: event21End
+ })
},
hasComponent: jest.fn().mockReturnValue(false),
}]
@@ -146,13 +146,13 @@ describe('fullcalendar/freeBusyResourceEventSourceFunction test suite', () => {
canModifyAllDay: jest.fn().mockReturnValue(true),
startDate: {
getInTimezone: jest.fn().mockReturnValue({
- jsDate: event31Start,
- }),
+ jsDate: event31Start
+ })
},
endDate: {
getInTimezone: jest.fn().mockReturnValue({
- jsDate: event31End,
- }),
+ jsDate: event31End
+ })
},
hasComponent: jest.fn().mockReturnValue(false),
color: 'red',
@@ -219,8 +219,7 @@ describe('fullcalendar/freeBusyResourceEventSourceFunction test suite', () => {
davUrl: 'url1',
objectType: 'VEVENT',
percent: null,
- hasAlarms: false,
- },
+ }
},
{
id: '1###1-2',
@@ -228,7 +227,7 @@ describe('fullcalendar/freeBusyResourceEventSourceFunction test suite', () => {
allDay: false,
start: event12Start,
end: event12End,
- classNames: ['fc-event-nc-cancelled'],
+ classNames: [ 'fc-event-nc-cancelled' ],
extendedProps: {
objectId: '1',
recurrenceId: 456,
@@ -240,8 +239,7 @@ describe('fullcalendar/freeBusyResourceEventSourceFunction test suite', () => {
davUrl: 'url1',
objectType: 'VEVENT',
percent: null,
- hasAlarms: false,
- },
+ }
},
{
id: '1###1-3',
@@ -249,7 +247,7 @@ describe('fullcalendar/freeBusyResourceEventSourceFunction test suite', () => {
allDay: false,
start: event13Start,
end: event13End,
- classNames: ['fc-event-nc-tentative', 'fc-event-nc-alarms'],
+ classNames: [ 'fc-event-nc-tentative', 'fc-event-nc-alarms' ],
extendedProps: {
objectId: '1',
recurrenceId: 789,
@@ -261,8 +259,7 @@ describe('fullcalendar/freeBusyResourceEventSourceFunction test suite', () => {
davUrl: 'url1',
objectType: 'VEVENT',
percent: null,
- hasAlarms: true,
- },
+ }
},
{
id: '2###2-1',
@@ -282,8 +279,7 @@ describe('fullcalendar/freeBusyResourceEventSourceFunction test suite', () => {
davUrl: 'url2',
objectType: 'VEVENT',
percent: null,
- hasAlarms: false,
- },
+ }
},
{
id: '4###3-1',
@@ -303,12 +299,11 @@ describe('fullcalendar/freeBusyResourceEventSourceFunction test suite', () => {
davUrl: 'url4',
objectType: 'VEVENT',
percent: null,
- hasAlarms: false,
},
backgroundColor: '#ff0000',
borderColor: '#ff0000',
textColor: '#eeeeee',
- },
+ }
])
expect(eventComponentSet1[0].startDate.getInTimezone).toHaveBeenCalledTimes(1)
@@ -437,16 +432,16 @@ describe('fullcalendar/freeBusyResourceEventSourceFunction test suite', () => {
isLight
.mockImplementation(() => false)
- const event1Start = new Date(2020, 1, 1, 10, 0, 0, 0)
- const event1End = new Date(2020, 1, 1, 15, 0, 0, 0)
- const event2Start = new Date(2020, 1, 2, 10, 0, 0, 0)
- const event2End = new Date(2020, 1, 2, 15, 0, 0, 0)
- const event3Start = new Date(2020, 1, 3, 10, 0, 0, 0)
- const event3End = new Date(2020, 1, 3, 15, 0, 0, 0)
- const event4Start = new Date(2020, 5, 5, 0, 0, 0, 0)
- const event4End = new Date(2020, 5, 6, 0, 0, 0, 0)
- const event5Start = new Date(2020, 6, 10, 10, 0, 0, 0)
- const event5End = new Date(2020, 6, 10, 10, 0, 0, 0)
+ const event1Start = new Date(2020, 1, 1, 10, 0, 0, 0);
+ const event1End = new Date(2020, 1, 1, 15, 0, 0, 0);
+ const event2Start = new Date(2020, 1, 2, 10, 0, 0, 0);
+ const event2End = new Date(2020, 1, 2, 15, 0, 0, 0);
+ const event3Start = new Date(2020, 1, 3, 10, 0, 0, 0);
+ const event3End = new Date(2020, 1, 3, 15, 0, 0, 0);
+ const event4Start = new Date(2020, 5, 5, 0, 0, 0, 0);
+ const event4End = new Date(2020, 5, 6, 0, 0, 0, 0);
+ const event5Start = new Date(2020, 6, 10, 10, 0, 0, 0);
+ const event5End = new Date(2020, 6, 10, 10, 0, 0, 0);
const eventComponentSet = [{
name: 'VTODO',
@@ -457,13 +452,13 @@ describe('fullcalendar/freeBusyResourceEventSourceFunction test suite', () => {
canModifyAllDay: jest.fn().mockReturnValue(false),
startDate: {
getInTimezone: jest.fn().mockReturnValue({
- jsDate: event1Start,
- }),
+ jsDate: event1Start
+ })
},
endDate: {
getInTimezone: jest.fn().mockReturnValue({
- jsDate: event1End,
- }),
+ jsDate: event1End
+ })
},
hasComponent: jest.fn().mockReturnValue(false),
percent: null,
@@ -476,13 +471,13 @@ describe('fullcalendar/freeBusyResourceEventSourceFunction test suite', () => {
canModifyAllDay: jest.fn().mockReturnValue(false),
startDate: {
getInTimezone: jest.fn().mockReturnValue({
- jsDate: event2Start,
- }),
+ jsDate: event2Start
+ })
},
endDate: {
getInTimezone: jest.fn().mockReturnValue({
- jsDate: event2End,
- }),
+ jsDate: event2End
+ })
},
hasComponent: jest.fn().mockReturnValue(false),
percent: null,
@@ -495,13 +490,13 @@ describe('fullcalendar/freeBusyResourceEventSourceFunction test suite', () => {
canModifyAllDay: jest.fn().mockReturnValue(false),
startDate: {
getInTimezone: jest.fn().mockReturnValue({
- jsDate: event3Start,
- }),
+ jsDate: event3Start
+ })
},
endDate: {
getInTimezone: jest.fn().mockReturnValue({
- jsDate: event3End,
- }),
+ jsDate: event3End
+ })
},
hasComponent: jest.fn().mockReturnValue(false),
percent: 99,
@@ -514,13 +509,13 @@ describe('fullcalendar/freeBusyResourceEventSourceFunction test suite', () => {
canModifyAllDay: jest.fn().mockReturnValue(false),
startDate: {
getInTimezone: jest.fn().mockReturnValue({
- jsDate: event4Start,
- }),
+ jsDate: event4Start
+ })
},
endDate: {
getInTimezone: jest.fn().mockReturnValue({
- jsDate: event4End,
- }),
+ jsDate: event4End
+ })
},
hasComponent: jest.fn().mockReturnValue(false),
title: 'This task has a title',
@@ -534,13 +529,13 @@ describe('fullcalendar/freeBusyResourceEventSourceFunction test suite', () => {
canModifyAllDay: jest.fn().mockReturnValue(false),
startDate: {
getInTimezone: jest.fn().mockReturnValue({
- jsDate: event5Start,
- }),
+ jsDate: event5Start
+ })
},
endDate: {
getInTimezone: jest.fn().mockReturnValue({
- jsDate: event5End,
- }),
+ jsDate: event5End
+ })
},
hasComponent: jest.fn().mockReturnValue(false),
title: 'This task has a title and percent',
@@ -595,7 +590,6 @@ describe('fullcalendar/freeBusyResourceEventSourceFunction test suite', () => {
objectType: 'VTODO',
percent: null,
recurrenceId: 123,
- hasAlarms: false,
},
id: '1###1',
start: event1End,
@@ -617,7 +611,6 @@ describe('fullcalendar/freeBusyResourceEventSourceFunction test suite', () => {
objectType: 'VTODO',
percent: null,
recurrenceId: 123,
- hasAlarms: false,
},
id: '1###2',
start: event2End,
@@ -639,7 +632,6 @@ describe('fullcalendar/freeBusyResourceEventSourceFunction test suite', () => {
objectType: 'VTODO',
percent: 99,
recurrenceId: 123,
- hasAlarms: false,
},
id: '1###3',
start: event3End,
@@ -661,7 +653,6 @@ describe('fullcalendar/freeBusyResourceEventSourceFunction test suite', () => {
objectType: 'VTODO',
percent: null,
recurrenceId: 123,
- hasAlarms: false,
},
id: '1###4',
start: event4End,
@@ -683,7 +674,6 @@ describe('fullcalendar/freeBusyResourceEventSourceFunction test suite', () => {
objectType: 'VTODO',
percent: 99,
recurrenceId: 123,
- hasAlarms: false,
},
id: '1###5',
start: event5End,
diff --git a/tests/javascript/unit/fullcalendar/rendering/eventDidMount.test.js b/tests/javascript/unit/fullcalendar/rendering/eventDidMount.test.js
index fcafb883..d48460df 100644
--- a/tests/javascript/unit/fullcalendar/rendering/eventDidMount.test.js
+++ b/tests/javascript/unit/fullcalendar/rendering/eventDidMount.test.js
@@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
-import eventRender from '../../../../../src/fullcalendar/rendering/eventDidMount.js'
+import eventRender from "../../../../../src/fullcalendar/rendering/eventDidMount.js";
describe('fullcalendar/eventDidMount test suite', () => {
@@ -82,6 +82,8 @@ describe('fullcalendar/eventDidMount test suite', () => {
}
eventRender({ event, el })
+
+ expect(el.outerHTML).toEqual('<div class="fc-event-nc-alarms" data-object-id="object123" data-recurrence-id="recurrence456"><div class="fc-content"><span class="fc-time">2pm</span><span class="fc-title">Title 123</span><span class="icon-event-reminder icon-event-reminder--dark"></span></div></div>')
})
it('should add an alarm bell icon if event has an alarm - light', () => {
@@ -112,6 +114,73 @@ describe('fullcalendar/eventDidMount test suite', () => {
}
eventRender({ event, el })
+
+ expect(el.outerHTML).toEqual('<div class="fc-event-nc-alarms" data-object-id="object123" data-recurrence-id="recurrence456"><div class="fc-content"><span class="fc-time">2pm</span><span class="fc-title">Title 123</span><span class="icon-event-reminder icon-event-reminder--light"></span></div></div>')
})
+ // TODO: fix me later
+ // it('should prepend a checkbox before tasks - incomplete', () => {
+ // const fcTime = document.createElement('span')
+ // fcTime.classList.add('fc-time')
+ // fcTime.appendChild(document.createTextNode('2pm'))
+ // const fcTitle = document.createElement('span')
+ // fcTitle.classList.add('fc-title')
+ // fcTitle.appendChild(document.createTextNode('Title 123'))
+ //
+ // const fcContent = document.createElement('div')
+ // fcContent.classList.add('fc-content')
+ // fcContent.appendChild(fcTime)
+ // fcContent.appendChild(fcTitle)
+ //
+ // const el = document.createElement('div')
+ // el.classList.add('fc-event-nc-task')
+ // el.appendChild(fcContent)
+ //
+ // const event = {
+ // source: {},
+ // extendedProps: {
+ // objectId: 'object123',
+ // recurrenceId: 'recurrence456',
+ // darkText: false,
+ // percent: 50,
+ // },
+ // }
+ //
+ // eventRender({ event, el })
+ //
+ // expect(el.outerHTML).toEqual('<div class="fc-event-nc-task" data-object-id="object123" data-recurrence-id="recurrence456"><div class="fc-content"><span class="icon-event-task icon-event-task--light"></span><span class="fc-time">2pm</span><span class="fc-title">Title 123</span></div></div>')
+ // })
+ //
+ // it('should prepend a checkbox before tasks - completed', () => {
+ // const fcTime = document.createElement('span')
+ // fcTime.classList.add('fc-time')
+ // fcTime.appendChild(document.createTextNode('2pm'))
+ // const fcTitle = document.createElement('span')
+ // fcTitle.classList.add('fc-title')
+ // fcTitle.appendChild(document.createTextNode('Title 123'))
+ //
+ // const fcContent = document.createElement('div')
+ // fcContent.classList.add('fc-content')
+ // fcContent.appendChild(fcTime)
+ // fcContent.appendChild(fcTitle)
+ //
+ // const el = document.createElement('div')
+ // el.classList.add('fc-event-nc-task')
+ // el.appendChild(fcContent)
+ //
+ // const event = {
+ // source: {},
+ // extendedProps: {
+ // objectId: 'object123',
+ // recurrenceId: 'recurrence456',
+ // darkText: false,
+ // percent: 100,
+ // },
+ // }
+ //
+ // eventRender({ event, el })
+ //
+ // expect(el.outerHTML).toEqual('<div class="fc-event-nc-task" data-object-id="object123" data-recurrence-id="recurrence456"><div class="fc-content"><span class="icon-event-task icon-event-task--light icon-event-task--checked--light"></span><span class="fc-time">2pm</span><span class="fc-title">Title 123</span></div></div>')
+ // })
+
})