Skip to content

Commit

Permalink
Update build-meetings.test.js
Browse files Browse the repository at this point in the history
  • Loading branch information
anshgoyalevil authored Sep 13, 2024
1 parent 8e3c1de commit ace426f
Showing 1 changed file with 0 additions and 44 deletions.
44 changes: 0 additions & 44 deletions tests/build-meetings.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,48 +70,4 @@ describe('buildMeetings', () => {
}
});

it('should handle undefined CALENDAR_SERVICE_ACCOUNT', async () => {
delete process.env.CALENDAR_SERVICE_ACCOUNT;

google.calendar().events.list.mockResolvedValue({ data: { items: [] } });

await buildMeetings(outputFilePath);

expect(google.auth.GoogleAuth).toHaveBeenCalledWith({
scopes: ['https://www.googleapis.com/auth/calendar'],
credentials: undefined,
});

const fileContent = readFileSync(outputFilePath, 'utf8');
expect(fileContent).toBe('[]');
});

it('should throw an error if authentication fails', async () => {
google.auth.GoogleAuth.mockImplementation(() => {
throw new Error('Authentication failed');
});

try {
await buildMeetings(outputFilePath)
} catch (err) {
expect(err.message).toContain('Authentication failed')
}
});

it('should handle file write errors', async () => {
google.auth.GoogleAuth.mockImplementation(() => ({
getClient: jest.fn(),
}));

google.calendar().events.list.mockResolvedValue({ data: { items: mockEvents } });

const invalidPath = '/root/invalid_dir/meetings.json';

try {
await buildMeetings(invalidPath);
} catch (err) {
expect(err.message).toMatch(/ENOENT|EACCES/);
}
});

});

0 comments on commit ace426f

Please sign in to comment.