All files / src/converter/galactic galacticCoordinate.spec.ts

100% Statements 28/28
100% Branches 7/7
100% Functions 0/0
100% Lines 28/28

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 321x   1x   1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x   1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
import { describe, expect, test } from 'vitest';
 
import { GalacticCoordinate } from './galacticCoordinate';
 
describe('Galactic Coordinate Converter', () => {
  describe('toGlyph', () => {
    test('with valid coordinate', () => {
      const result = GalacticCoordinate({ code: '0C55:00D5:0922:0234' }).toGlyph();
      expect(result.isSuccess, result.errorMessage).toBeTruthy();
      expect(result.value.code).toBe('023456123456');
    });
    test('with invalid coordinate', () => {
      const result = GalacticCoordinate({ code: '0000C55:00D5:0922:0234' }).toGlyph();
      expect(result.isSuccess, result.errorMessage).toBeFalsy();
    });
  });
 
  describe('toVoxel', () => {
    test('with valid coordinate', () => {
      const result = GalacticCoordinate({ code: '0C55:00D5:0922:0234' }).toVoxel();
      expect(result.isSuccess, result.errorMessage).toBeTruthy();
      expect(result.value.VoxelX).toBe(1110);
      expect(result.value.VoxelY).toBe(86);
      expect(result.value.VoxelZ).toBe(291);
    });
    test('with invalid coordinate', () => {
      const result = GalacticCoordinate({ code: '0000C55:00D5:0922:0234' }).toVoxel();
      expect(result.isSuccess, result.errorMessage).toBeFalsy();
    });
  });
});