Skip to content

Commit 1f5e014

Browse files
committed
Add API tests for expected filtering on created
1 parent cdd5656 commit 1f5e014

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

test/api/environments.test.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,49 @@ module.exports = () => {
3636
expect(environments[0].id).to.equal('CmCvjNbg');
3737
});
3838

39+
it('should successfully return environments that were created between two provided dates', async () => {
40+
const from = new Date('2019-08-09 15:50:00').getTime();
41+
const to = new Date('2019-08-09 19:00:00').getTime();
42+
const response = await request(server).get(`/api/environments?filter[created][from]=${from}&filter[created][to]=${to}`);
43+
44+
expect(response.status).to.equal(200);
45+
const environments = response.body.data;
46+
expect(environments).to.lengthOf(2); // Assuming all environments were created in 2023
47+
expect(environments[0].id).to.equal('TDI59So3d');
48+
expect(environments[1].id).to.equal('EIDO13i3D');
49+
});
50+
51+
it('should successfully return environments that were created from provided date', async () => {
52+
const from = new Date('2019-08-09 15:50:00').getTime();
53+
const response = await request(server).get(`/api/environments?filter[created][from]=${from}`);
54+
55+
expect(response.status).to.equal(200);
56+
const environments = response.body.data;
57+
expect(environments).to.lengthOf(3); // Assuming all environments were created in 2023
58+
expect(environments[0].id).to.equal('CmCvjNbg');
59+
expect(environments[1].id).to.equal('TDI59So3d');
60+
expect(environments[2].id).to.equal('EIDO13i3D');
61+
});
62+
63+
it('should successfully return environments that were created to provided date', async () => {
64+
const to = new Date('2019-08-09 19:00:00').getTime();
65+
const response = await request(server).get(`/api/environments?filter[created][to]=${to}`);
66+
67+
expect(response.status).to.equal(200);
68+
const environments = response.body.data;
69+
console.log('-------- Environments:');
70+
console.log(environments);
71+
expect(environments).to.lengthOf(8); // Assuming all environments were created in 2023
72+
expect(environments[0].id).to.equal('TDI59So3d');
73+
expect(environments[1].id).to.equal('EIDO13i3D');
74+
expect(environments[2].id).to.equal('KGIS12DS');
75+
expect(environments[3].id).to.equal('VODdsO12d');
76+
expect(environments[4].id).to.equal('GIDO1jdkD');
77+
expect(environments[5].id).to.equal('8E4aZTjY');
78+
expect(environments[6].id).to.equal('Dxi029djX');
79+
expect(environments[7].id).to.equal('eZF99lH6');
80+
});
81+
3982
it('should successfully apply filter for environments ids', async () => {
4083
const response = await request(server).get('/api/environments?filter[ids]=8E4aZTjY');
4184

0 commit comments

Comments
 (0)