-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.test.js
More file actions
24 lines (21 loc) · 1004 Bytes
/
Copy pathserver.test.js
File metadata and controls
24 lines (21 loc) · 1004 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const request = require('supertest');
const app = require('./server');
describe('GET /time endpoint', () => {
it('should return the current UTC time', async () => {
const response = await request(app).get('/time');
expect(response.statusCode).toBe(200);
expect(response.body.currentTime).toBeDefined();
});
it('should return the adjusted time when a valid timezone is provided', async () => {
const timezone = 'America/New_York';
const response = await request(app).get(`/time?timezone=${timezone}`);
expect(response.statusCode).toBe(200);
expect(response.body.adjustedTime).toBeDefined();
});
it('should not return an adjusted time when an invalid timezone is provided', async () => {
const timezone = 'Invalid/Timezone';
const response = await request(app).get(`/time?timezone=${timezone}`);
expect(response.statusCode).toBe(200);
expect(response.body.adjustedTime).toBeFalsy();
});
});