Compare commits
No commits in common. "ff32bb430dd051d6c2f2d11ecd64107d86b7ef51" and "9a0a62675c3acbe698d89b7b083a9348cc5e06d9" have entirely different histories.
ff32bb430d
...
9a0a62675c
1 changed files with 12 additions and 5 deletions
|
@ -1,5 +1,4 @@
|
||||||
import ICAL from 'ical.js';
|
import fs from 'fs';
|
||||||
import fs from 'fs';
|
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
// Describe the test suite for Calendar Utility Functions
|
// Describe the test suite for Calendar Utility Functions
|
||||||
|
@ -34,11 +33,19 @@ describe('Calendar Utility Functions', () => {
|
||||||
|
|
||||||
// Test case: reading data from a file
|
// Test case: reading data from a file
|
||||||
it('reads data from a file', async () => {
|
it('reads data from a file', async () => {
|
||||||
const testCalendar = { url: './test_calendars/eat_time_zone_event.ics' };
|
const testCalendar = { url: './test_calendars/work_task_calendar.ics' };
|
||||||
|
|
||||||
|
// Mock the fs.readFileSync method to return specific test data
|
||||||
|
jest.spyOn(fs, 'readFileSync').mockReturnValue('file data');
|
||||||
|
|
||||||
// Call the fetchCalendarData function with the test calendar object
|
// Call the fetchCalendarData function with the test calendar object
|
||||||
const result = await fetchCalendarData(testCalendar);
|
const result = await fetchCalendarData(testCalendar);
|
||||||
|
|
||||||
// Assert that the fetched result's data matches the expected file data
|
// Assert that the fetched result's data matches the expected file data
|
||||||
expect(ICAL.parse(result.data)).toBe('file data');
|
expect(result.data).toBe('file data');
|
||||||
|
|
||||||
|
// Restore the original fs.readFileSync method after the test
|
||||||
|
fs.readFileSync.mockRestore();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
Loading…
Add table
Reference in a new issue