add unit and integration tests

This commit is contained in:
Ronid1 2024-03-05 11:18:49 -08:00
parent b67dee1eed
commit 19e049642b
2 changed files with 39 additions and 3 deletions

View File

@ -101,12 +101,12 @@ describe('Gantt diagram', () => {
title Adding GANTT diagram to mermaid
excludes weekdays 2014-01-10
todayMarker off
section team's critical event
deadline A :milestone, crit, deadlineA, 2024-02-01, 0
deadline B :milestone, crit, deadlineB, 2024-02-15, 0
boss on leave :bossaway, 2024-01-28, 2024-02-11
section new intern
onboarding :onboarding, 2024-01-02, 1w
literature review :litreview, 2024-01-02, 10d
@ -573,7 +573,28 @@ describe('Gantt diagram', () => {
`
);
});
it('should render a gantt diagram exculding friday and saturday', () => {
imgSnapshotTest(
`gantt
title A Gantt Diagram
dateFormat YYYY-MM-DD
excludes weekends
weekend friday
section Section1
A task :a1, 2024-02-28, 10d`
);
});
it('should render a gantt diagram exculding saturday and sunday', () => {
imgSnapshotTest(
`gantt
title A Gantt Diagram
dateFormat YYYY-MM-DD
excludes weekends
weekend saturday
section Section1
A task :a1, 2024-02-28, 10d`
);
});
it('should render when compact is true', () => {
imgSnapshotTest(
`

View File

@ -267,6 +267,21 @@ describe('when using the ganttDb', function () {
expect(tasks[6].task).toEqual('test7');
});
it('should ignore weekends starting on friday', function () {
ganttDb.setDateFormat('YYYY-MM-DD');
ganttDb.setExcludes('weekends');
ganttDb.setWeekend('friday');
ganttDb.addSection('friday-saturday weekends skip test');
ganttDb.addTask('test1', 'id1,2024-02-28, 3d');
const tasks = ganttDb.getTasks();
expect(tasks[0].startTime).toEqual(dayjs('2024-02-28', 'YYYY-MM-DD').toDate());
expect(tasks[0].endTime).toEqual(dayjs('2024-03-04', 'YYYY-MM-DD').toDate());
expect(tasks[0].id).toEqual('id1');
expect(tasks[0].task).toEqual('test1');
});
it('should maintain the order in which tasks are created', function () {
ganttDb.setAccTitle('Project Execution');
ganttDb.setDateFormat('YYYY-MM-DD');