diff --git a/package-lock.json b/package-lock.json index ede4e12..cce0b2b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@nmscd/coordinate-conversion", - "version": "1.2.1", + "version": "1.2.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@nmscd/coordinate-conversion", - "version": "1.2.1", + "version": "1.2.2", "license": "MIT", "devDependencies": { "@types/node": "^20.11.19", diff --git a/package.json b/package.json index 8027d8e..5bf744c 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/converter/portal/portalCode.spec.ts b/src/converter/portal/portalCode.spec.ts index 0caec8d..528610e 100644 --- a/src/converter/portal/portalCode.spec.ts +++ b/src/converter/portal/portalCode.spec.ts @@ -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(); diff --git a/src/functions/convertCoords/coords2XYZ.spec.ts b/src/functions/convertCoords/coords2XYZ.spec.ts index 7ca0524..c76d5a3 100644 --- a/src/functions/convertCoords/coords2XYZ.spec.ts +++ b/src/functions/convertCoords/coords2XYZ.spec.ts @@ -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'); diff --git a/src/functions/convertGlyphs/glyphs2Coords.ts b/src/functions/convertGlyphs/glyphs2Coords.ts index 4406925..44b9065 100644 --- a/src/functions/convertGlyphs/glyphs2Coords.ts +++ b/src/functions/convertGlyphs/glyphs2Coords.ts @@ -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(':'); } diff --git a/src/index.ts b/src/index.ts index 4cffe1d..07b6b14 100644 --- a/src/index.ts +++ b/src/index.ts @@ -23,6 +23,5 @@ export { type GlyphOutput, type VoxelCoordinates, type VoxelInput, - type VoxelOutput + type VoxelOutput, }; -