All files / src/converter/voxel voxelCoordinate.spec.ts

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

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 32 33 34 35 36 37 38 39 40 41 42 431x   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 1x 1x 1x 1x 1x 1x 1x 1x 1x  
import { describe, expect, test } from 'vitest';
 
import { VoxelCoordinate } from './voxelCoordinate';
import type { VoxelCoordinates } from '@/types/voxelTypes';
 
describe('Voxel Coordinate Converter', () => {
  const validCoords: VoxelCoordinates = {
    VoxelX: -1781,
    VoxelY: 3,
    VoxelZ: 197,
    PlanetIndex: 1,
    SolarSystemIndex: 228,
  };
  const inValidCoords: VoxelCoordinates = {
    ...validCoords,
    VoxelX: 10000000,
  };
 
  describe('toGlyph', () => {
    test('with valid coordinate', () => {
      const result = VoxelCoordinate(validCoords).toGlyph();
      expect(result.isSuccess, result.errorMessage).toBeTruthy();
      expect(result.value.code).toBe('10E4030C590B');
    });
    test('with invalid coordinate', () => {
      const result = VoxelCoordinate(inValidCoords).toGlyph();
      expect(result.isSuccess, result.errorMessage).toBeFalsy();
    });
  });
 
  describe('toGalacticCoordinates', () => {
    test('with valid coordinate', () => {
      const result = VoxelCoordinate(validCoords).toGalacticCoordinates();
      expect(result.isSuccess, result.errorMessage).toBeTruthy();
      expect(result.value.code).toBe('010A:0082:08C4:00E4');
    });
    test('with invalid coordinate', () => {
      const result = VoxelCoordinate(inValidCoords).toGalacticCoordinates();
      expect(result.isSuccess, result.errorMessage).toBeFalsy();
    });
  });
});