Skip to content

Commit

Permalink
Add querysting filter support for NORAD id's
Browse files Browse the repository at this point in the history
jakewmeyer committed Aug 8, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 34fb615 commit 329d632
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/builders/launch-query.js
Original file line number Diff line number Diff line change
@@ -128,6 +128,10 @@ module.exports = (q) => {
query['rocket.second_stage.payloads.payload_id'] = q.payload_id;
}

if (q.norad_id) {
query['rocket.second_stage.payloads.norad_id'] = parseInt(q.norad_id, 10);
}

if (q.customer) {
query['rocket.second_stage.payloads.customers'] = q.customer;
}
10 changes: 10 additions & 0 deletions test/builders/launch-query.test.js
Original file line number Diff line number Diff line change
@@ -226,6 +226,16 @@ test('It should return launch of BulgariaSat-1', async () => {
});
});

test('It should return Iridium NEXT 7 with the correct NORAD id', async () => {
const response = await request(app.callback()).get('/v2/launches?norad_id=43571');
expect(response.statusCode).toBe(200);
response.body.forEach((item) => {
item.rocket.second_stage.payloads.forEach((payload) => {
expect(payload).toHaveProperty('payload_id', 'Iridium NEXT 7');
});
});
});

test('It should return launches with Bulgaria Sat customer', async () => {
const response = await request(app.callback()).get('/v2/launches?customer=Bulgaria+Sat');
expect(response.statusCode).toBe(200);

0 comments on commit 329d632

Please sign in to comment.