Something went wrong. Try again.
TypeScript client for accessing TLE Community.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135import { getLacuna } from '../__utils__/get-lacuna';import { expectMatchesApiSchema } from '../__utils__/validate-schema';import { int } from '../core/util';import Lacuna from '../lacuna';
let lacuna: Lacuna;// A small box around the origin should contain at least one star - used as// shared fixture data (id/name/x/y/zone) for the rest of the tests below.let star: { id: number; name: string; x: number; y: number; zone: string } | undefined;
beforeAll(async () => { lacuna = await getLacuna();
const { result } = await lacuna.map.getStars({ x1: -5, y1: -5, x2: 5, y2: 5 }); const found = result?.stars?.[0];
if (found) { star = { id: int(found.id), name: found.name, x: found.x, y: found.y, zone: found.zone }; }});
test('getStars', () => { // Exercised in beforeAll to obtain fixture data - just assert it worked. expect(star).toBeDefined();});
test('getStarMap', async () => { const { result } = await lacuna.map.getStarMap({ left: -5, top: -5, right: 5, bottom: 5 });
expect(result?.stars).toBeDefined(); // Spec bug: live star items with no bodies omit the spec-required // `bodies` field entirely rather than sending `[]`. See README "Spec // Discrepancies" #19. // Spec bug: `influence` is spec-required `number` but the server sends // `null` for stars outside any station's jurisdiction. See README #18. expectMatchesApiSchema('map', 'get_star_map', result, [ { keyword: 'required', instancePath: '/stars/*' }, { keyword: 'type', instancePath: '/stars/*/influence' }, ]);});
test('checkStarForIncomingProbe', async () => { if (!star) { console.warn('Skipping: no star found near the origin to check for an incoming probe'); return; }
const { result } = await lacuna.map.checkStarForIncomingProbe({ star_id: star.id });
expectMatchesApiSchema('map', 'check_star_for_incoming_probe', result);});
test('getStar', async () => { if (!star) { console.warn('Skipping: no star found near the origin to view'); return; }
const { result } = await lacuna.map.getStar({ star_id: star.id });
expect(result?.star).toBeDefined(); // Spec bug: `influence` is spec-required `number` but arrives `null` for // stars outside any station's jurisdiction. See README #18. expectMatchesApiSchema('map', 'get_star', result, [ { keyword: 'type', instancePath: '/star/influence' }, ]);});
test('getStarByName', async () => { if (!star) { console.warn('Skipping: no star found near the origin to look up by name'); return; }
const { result } = await lacuna.map.getStarByName({ name: star.name });
expect(result?.star).toBeDefined(); // Spec bug: `influence` is spec-required `number` but arrives `null` for // stars outside any station's jurisdiction. See README #18. expectMatchesApiSchema('map', 'get_star_by_name', result, [ { keyword: 'type', instancePath: '/star/influence' }, ]);});
test('getStarByXy', async () => { if (!star) { console.warn('Skipping: no star found near the origin to look up by coordinates'); return; }
const { result } = await lacuna.map.getStarByXy({ x: star.x, y: star.y });
expect(result?.star).toBeDefined(); // Spec bug: `influence` is spec-required `number` but arrives `null` for // stars outside any station's jurisdiction. See README #18. expectMatchesApiSchema('map', 'get_star_by_xy', result, [ { keyword: 'type', instancePath: '/star/influence' }, ]);});
test('searchStars', async () => { if (!star) { console.warn('Skipping: no star found near the origin to search for'); return; }
const { result } = await lacuna.map.searchStars({ name: star.name });
expect(result?.stars).toBeDefined(); expectMatchesApiSchema('map', 'search_stars', result);});
test('probeSummaryFissures', async () => { const { result } = await lacuna.map.probeSummaryFissures({ zone: star?.zone });
expectMatchesApiSchema('map', 'probe_summary_fissures', result);});
test('viewLaws', async () => { if (!star) { console.warn('Skipping: no star found near the origin to view laws for'); return; }
const { result } = await lacuna.map.viewLaws({ star_id: star.id });
expect(result?.laws).toBeDefined(); // Spec bug: 1.4.0 renamed the law key `descripition` -> `description` and // made it required, but the live server still sends the misspelled key. // See README #19. expectMatchesApiSchema('map', 'view_laws', result, [ { keyword: 'required', instancePath: '/laws/*' }, ]);});