Skip to content

Commit 18ba3df

Browse files
committed
update core query test with async
1 parent 7ae76a1 commit 18ba3df

File tree

1 file changed

+55
-66
lines changed

1 file changed

+55
-66
lines changed

test/builders/core-query.test.js

Lines changed: 55 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -12,101 +12,90 @@ beforeAll((done) => {
1212
// Core Query Test
1313
//------------------------------------------------------------
1414

15-
test('It should return core serial B1041', () => {
16-
return request(app).get('/v2/parts/cores?core_serial=B1041').then((response) => {
17-
expect(response.statusCode).toBe(200);
18-
response.body.forEach((item) => {
19-
expect(item).toHaveProperty('core_serial', 'B1041');
20-
});
15+
test('It should return core serial B1041', async () => {
16+
const response = await request(app).get('/v2/parts/cores?core_serial=B1041');
17+
expect(response.statusCode).toBe(200);
18+
response.body.forEach((item) => {
19+
expect(item).toHaveProperty('core_serial', 'B1041');
2120
});
2221
});
2322

24-
test('It should return all block 4 cores', () => {
25-
return request(app).get('/v2/parts/cores?block=4').then((response) => {
26-
expect(response.statusCode).toBe(200);
27-
response.body.forEach((item) => {
28-
expect(item).toHaveProperty('block');
29-
});
23+
test('It should return all block 4 cores', async () => {
24+
const response = await request(app).get('/v2/parts/cores?block=4');
25+
expect(response.statusCode).toBe(200);
26+
response.body.forEach((item) => {
27+
expect(item).toHaveProperty('block');
3028
});
3129
});
3230

33-
test('It should return all cores with active status', () => {
34-
return request(app).get('/v2/parts/cores?status=active').then((response) => {
35-
expect(response.statusCode).toBe(200);
36-
response.body.forEach((item) => {
37-
expect(item).toHaveProperty('status', 'active');
38-
});
31+
test('It should return all cores with active status', async () => {
32+
const response = await request(app).get('/v2/parts/cores?status=active');
33+
expect(response.statusCode).toBe(200);
34+
response.body.forEach((item) => {
35+
expect(item).toHaveProperty('status', 'active');
3936
});
4037
});
4138

42-
test('It should return core B1041 with the correct launch date', () => {
43-
return request(app).get('/v2/parts/cores?original_launch=2017-10-09T12:37:00Z').then((response) => {
44-
expect(response.statusCode).toBe(200);
45-
response.body.forEach((item) => {
46-
expect(item).toHaveProperty('original_launch', '2017-10-09T12:37:00Z');
47-
});
39+
test('It should return core B1041 with the correct launch date', async () => {
40+
const response = await request(app).get('/v2/parts/cores?original_launch=2017-10-09T12:37:00Z');
41+
expect(response.statusCode).toBe(200);
42+
response.body.forEach((item) => {
43+
expect(item).toHaveProperty('original_launch', '2017-10-09T12:37:00Z');
4844
});
4945
});
5046

51-
test('It should return core for Iridium NEXT 21-30', () => {
52-
return request(app).get('/v2/parts/cores?missions=Iridium+NEXT+21-30').then((response) => {
53-
expect(response.statusCode).toBe(200);
54-
response.body.forEach((item) => {
55-
expect(item).toHaveProperty('missions');
56-
});
47+
test('It should return core for Iridium NEXT 21-30', async () => {
48+
const response = await request(app).get('/v2/parts/cores?missions=Iridium+NEXT+21-30');
49+
expect(response.statusCode).toBe(200);
50+
response.body.forEach((item) => {
51+
expect(item).toHaveProperty('missions');
5752
});
5853
});
5954

60-
test('It should return core with an active status', () => {
61-
return request(app).get('/v2/parts/cores?status=active').then((response) => {
62-
expect(response.statusCode).toBe(200);
63-
response.body.forEach((item) => {
64-
expect(item).toHaveProperty('status', 'active');
65-
});
55+
test('It should return core with an active status', async () => {
56+
const response = await request(app).get('/v2/parts/cores?status=active');
57+
expect(response.statusCode).toBe(200);
58+
response.body.forEach((item) => {
59+
expect(item).toHaveProperty('status', 'active');
6660
});
6761
});
6862

69-
test('It should return cores with rtls attempts', () => {
70-
return request(app).get('/v2/parts/cores?rtls_attempt=true').then((response) => {
71-
expect(response.statusCode).toBe(200);
72-
response.body.forEach((item) => {
73-
expect(item).toHaveProperty('rtls_attempt', true);
74-
});
63+
test('It should return cores with rtls attempts', async () => {
64+
const response = await request(app).get('/v2/parts/cores?rtls_attempt=true');
65+
expect(response.statusCode).toBe(200);
66+
response.body.forEach((item) => {
67+
expect(item).toHaveProperty('rtls_attempt', true);
7568
});
7669
});
7770

78-
test('It should return cores with 1 rtls landings', () => {
79-
return request(app).get('/v2/parts/cores?rtls_landings=1').then((response) => {
80-
expect(response.statusCode).toBe(200);
81-
response.body.forEach((item) => {
82-
expect(item).toHaveProperty('rtls_landings', 1);
83-
});
71+
test('It should return cores with 1 rtls landings', async () => {
72+
const response = await request(app).get('/v2/parts/cores?rtls_landings=1');
73+
expect(response.statusCode).toBe(200);
74+
response.body.forEach((item) => {
75+
expect(item).toHaveProperty('rtls_landings', 1);
8476
});
8577
});
8678

87-
test('It should return cores with asds attempts', () => {
88-
return request(app).get('/v2/parts/cores?asds_attempt=true').then((response) => {
89-
expect(response.statusCode).toBe(200);
90-
response.body.forEach((item) => {
91-
expect(item).toHaveProperty('asds_attempt', true);
92-
});
79+
test('It should return cores with asds attempts', async () => {
80+
const response = await request(app).get('/v2/parts/cores?asds_attempt=true');
81+
expect(response.statusCode).toBe(200);
82+
response.body.forEach((item) => {
83+
expect(item).toHaveProperty('asds_attempt', true);
9384
});
9485
});
9586

96-
test('It should return cores with 1 asds landing', () => {
97-
return request(app).get('/v2/parts/cores?asds_landings=1').then((response) => {
98-
expect(response.statusCode).toBe(200);
99-
response.body.forEach((item) => {
100-
expect(item).toHaveProperty('asds_landings', 1);
101-
});
87+
test('It should return cores with 1 asds landing', async () => {
88+
const response = await request(app).get('/v2/parts/cores?asds_landings=1');
89+
expect(response.statusCode).toBe(200);
90+
response.body.forEach((item) => {
91+
expect(item).toHaveProperty('asds_landings', 1);
10292
});
10393
});
10494

105-
test('It should return cores with water landings', () => {
106-
return request(app).get('/v2/parts/cores?water_landing=true').then((response) => {
107-
expect(response.statusCode).toBe(200);
108-
response.body.forEach((item) => {
109-
expect(item).toHaveProperty('water_landing', true);
110-
});
95+
test('It should return cores with water landings', async () => {
96+
const response = await request(app).get('/v2/parts/cores?water_landing=true');
97+
expect(response.statusCode).toBe(200);
98+
response.body.forEach((item) => {
99+
expect(item).toHaveProperty('water_landing', true);
111100
});
112101
});

0 commit comments

Comments
 (0)