|
| 1 | + |
| 2 | +const request = require('supertest'); |
| 3 | +const app = require('../src/app'); |
| 4 | + |
| 5 | +beforeAll((done) => { |
| 6 | + app.on('ready', () => { |
| 7 | + done(); |
| 8 | + }); |
| 9 | +}); |
| 10 | + |
| 11 | +//------------------------------------------------------------ |
| 12 | +// Capsule V2 |
| 13 | +//------------------------------------------------------------ |
| 14 | + |
| 15 | +test('It should return all v2 capsules', () => { |
| 16 | + return request(app).get('/v2/parts/caps').then((response) => { |
| 17 | + expect(response.statusCode).toBe(200); |
| 18 | + response.body.forEach((item) => { |
| 19 | + expect(item).toHaveProperty('capsule_serial'); |
| 20 | + expect(item).toHaveProperty('capsule_id'); |
| 21 | + expect(item).toHaveProperty('status'); |
| 22 | + expect(item).toHaveProperty('original_launch'); |
| 23 | + expect(item.missions.length).toBeGreaterThan(0); |
| 24 | + expect(item).toHaveProperty('landings'); |
| 25 | + expect(item).toHaveProperty('type'); |
| 26 | + expect(item).toHaveProperty('details'); |
| 27 | + }); |
| 28 | + }); |
| 29 | +}); |
| 30 | + |
| 31 | +test('It should return capsule C101', () => { |
| 32 | + return request(app).get('/v2/parts/caps/C101').then((response) => { |
| 33 | + expect(response.statusCode).toBe(200); |
| 34 | + expect(response.body).toHaveProperty('capsule_serial', 'C101'); |
| 35 | + }); |
| 36 | +}); |
| 37 | + |
| 38 | +//------------------------------------------------------------ |
| 39 | +// Core V2 |
| 40 | +//------------------------------------------------------------ |
| 41 | + |
| 42 | +test('It should return all v2 cores', () => { |
| 43 | + return request(app).get('/v2/parts/cores').then((response) => { |
| 44 | + expect(response.statusCode).toBe(200); |
| 45 | + response.body.forEach((item) => { |
| 46 | + expect(item).toHaveProperty('core_serial'); |
| 47 | + expect(item).toHaveProperty('status'); |
| 48 | + expect(item).toHaveProperty('original_launch'); |
| 49 | + expect(item.missions.length).toBeGreaterThan(0); |
| 50 | + expect(item).toHaveProperty('rtls_attempt'); |
| 51 | + expect(item).toHaveProperty('rtls_landings'); |
| 52 | + expect(item).toHaveProperty('asds_attempt'); |
| 53 | + expect(item).toHaveProperty('asds_landings'); |
| 54 | + expect(item).toHaveProperty('water_landing'); |
| 55 | + expect(item).toHaveProperty('details'); |
| 56 | + }); |
| 57 | + }); |
| 58 | +}); |
| 59 | + |
| 60 | +test('It should return core B0007', () => { |
| 61 | + return request(app).get('/v2/parts/cores/B0007').then((response) => { |
| 62 | + expect(response.statusCode).toBe(200); |
| 63 | + expect(response.body).toHaveProperty('core_serial', 'B0007'); |
| 64 | + }); |
| 65 | +}); |
0 commit comments