Skip to content

Commit

Permalink
Merge pull request #58 from NMSCD/dev
Browse files Browse the repository at this point in the history
Fix unexpected edge case
  • Loading branch information
Lenni009 authored May 8, 2024
2 parents b0d941f + ccd55a1 commit 2184c8f
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@nmscd/coordinate-conversion",
"private": false,
"version": "1.2.1",
"version": "1.2.2",
"type": "module",
"description": "Library to convert NMS coordinates",
"main": "./dist/coordinate-conversion.js",
Expand Down
7 changes: 7 additions & 0 deletions src/converter/portal/portalCode.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ describe('Portal Coordinate Converter', () => {
expect(result.isSuccess).toBeTruthy();
expect(result.value.code).toBe('0C55:00D5:0922:0234');
});

test('with valid coordinate and last expected digit being a character', () => {
const result = PortalCode({ code: '405EA21107FF' }).toGalacticCoordinates();
expect(result.isSuccess).toBeTruthy();
expect(result.value.code).toBe('0FFE:0021:090F:005E');
});

test('with invalid coordinate', () => {
const result = PortalCode({ code: '0000023456123456' }).toGalacticCoordinates();
expect(result.isSuccess).toBeFalsy();
Expand Down
10 changes: 5 additions & 5 deletions src/functions/convertCoords/coords2XYZ.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ describe('Galactic to XYZ', () => {
});
test('output is the correct format', () => {
const coords = coords2XYZ('0C55:00D5:0922:0234');
expect(coords!.voxelX).toBe(1110);
expect(coords!.voxelY).toBe(86);
expect(coords!.voxelZ).toBe(291);
expect(coords!.planetIndex).toBe(0);
expect(coords!.solarSystemIndex).toBe(564);
expect(coords.voxelX).toBe(1110);
expect(coords.voxelY).toBe(86);
expect(coords.voxelZ).toBe(291);
expect(coords.planetIndex).toBe(0);
expect(coords.solarSystemIndex).toBe(564);
});
test('invalid input', () => {
const coords = coords2XYZ('00000C55:00D5:0922:0234');
Expand Down
2 changes: 1 addition & 1 deletion src/functions/convertGlyphs/glyphs2Coords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function glyphs2Coords(glyphs: string) {
const coordData = [coords_x, coords_y, coords_z];
const coordinates = coordData.map((coord) => coord.toString(16).toUpperCase().padStart(4, '0'));

coordinates[3] = system_idx.padStart(4, '0'); // NoSonar the 4 is to bump it to a length of 4
coordinates[3] = system_idx.padStart(4, '0').toUpperCase(); // NoSonar the 4 is to bump it to a length of 4

return coordinates.join(':');
}
3 changes: 1 addition & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,5 @@ export {
type GlyphOutput,
type VoxelCoordinates,
type VoxelInput,
type VoxelOutput
type VoxelOutput,
};

0 comments on commit 2184c8f

Please sign in to comment.