|
| 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 | +// Core Query Test |
| 13 | +//------------------------------------------------------------ |
| 14 | + |
| 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 | + }); |
| 21 | + }); |
| 22 | +}); |
| 23 | + |
| 24 | +test('It should return all cores with active status', () => { |
| 25 | + return request(app).get('/v2/parts/cores?status=active').then((response) => { |
| 26 | + expect(response.statusCode).toBe(200); |
| 27 | + response.body.forEach((item) => { |
| 28 | + expect(item).toHaveProperty('status', 'active'); |
| 29 | + }); |
| 30 | + }); |
| 31 | +}); |
| 32 | + |
| 33 | +test('It should return core B1041 with the correct launch date', () => { |
| 34 | + return request(app).get('/v2/parts/cores?original_launch=2017-10-09T12:37:00Z').then((response) => { |
| 35 | + expect(response.statusCode).toBe(200); |
| 36 | + response.body.forEach((item) => { |
| 37 | + expect(item).toHaveProperty('original_launch', '2017-10-09T12:37:00Z'); |
| 38 | + }); |
| 39 | + }); |
| 40 | +}); |
| 41 | + |
| 42 | +test('It should return core for Iridium NEXT 21-30', () => { |
| 43 | + return request(app).get('/v2/parts/cores?missions=Iridium+NEXT+21-30').then((response) => { |
| 44 | + expect(response.statusCode).toBe(200); |
| 45 | + response.body.forEach((item) => { |
| 46 | + expect(item).toHaveProperty('missions'); |
| 47 | + }); |
| 48 | + }); |
| 49 | +}); |
| 50 | + |
| 51 | +test('It should return core with an active status', () => { |
| 52 | + return request(app).get('/v2/parts/cores?status=active').then((response) => { |
| 53 | + expect(response.statusCode).toBe(200); |
| 54 | + response.body.forEach((item) => { |
| 55 | + expect(item).toHaveProperty('status', 'active'); |
| 56 | + }); |
| 57 | + }); |
| 58 | +}); |
| 59 | + |
| 60 | +test('It should return cores with rtls attempts', () => { |
| 61 | + return request(app).get('/v2/parts/cores?rtls_attempt=true').then((response) => { |
| 62 | + expect(response.statusCode).toBe(200); |
| 63 | + response.body.forEach((item) => { |
| 64 | + expect(item).toHaveProperty('rtls_attempt', true); |
| 65 | + }); |
| 66 | + }); |
| 67 | +}); |
| 68 | + |
| 69 | +test('It should return cores with 1 rtls landings', () => { |
| 70 | + return request(app).get('/v2/parts/cores?rtls_landings=1').then((response) => { |
| 71 | + expect(response.statusCode).toBe(200); |
| 72 | + response.body.forEach((item) => { |
| 73 | + expect(item).toHaveProperty('rtls_landings', 1); |
| 74 | + }); |
| 75 | + }); |
| 76 | +}); |
| 77 | + |
| 78 | +test('It should return cores with asds attempts', () => { |
| 79 | + return request(app).get('/v2/parts/cores?asds_attempt=true').then((response) => { |
| 80 | + expect(response.statusCode).toBe(200); |
| 81 | + response.body.forEach((item) => { |
| 82 | + expect(item).toHaveProperty('asds_attempt', true); |
| 83 | + }); |
| 84 | + }); |
| 85 | +}); |
| 86 | + |
| 87 | +test('It should return cores with 1 asds landing', () => { |
| 88 | + return request(app).get('/v2/parts/cores?asds_landings=1').then((response) => { |
| 89 | + expect(response.statusCode).toBe(200); |
| 90 | + response.body.forEach((item) => { |
| 91 | + expect(item).toHaveProperty('asds_landings', 1); |
| 92 | + }); |
| 93 | + }); |
| 94 | +}); |
| 95 | + |
| 96 | +test('It should return cores with water landings', () => { |
| 97 | + return request(app).get('/v2/parts/cores?water_landing=true').then((response) => { |
| 98 | + expect(response.statusCode).toBe(200); |
| 99 | + response.body.forEach((item) => { |
| 100 | + expect(item).toHaveProperty('water_landing', true); |
| 101 | + }); |
| 102 | + }); |
| 103 | +}); |
0 commit comments