// import * as fc from 'fast-check'; import { describe, it, expect } from 'vitest'; import * as orbisCore from '../src'; describe('orbis-core', () => { describe('project', () => { it('throws error for invalid coordinates', () => { expect(() => orbisCore.project([-181, 90], ['Equirectangular'])).toThrowError(RangeError); expect(() => orbisCore.project([181, 90], ['Equirectangular'])).toThrowError(RangeError); expect(() => orbisCore.project([-180, 91], ['Equirectangular'])).toThrowError(RangeError); expect(() => orbisCore.project([-180, -91], ['Equirectangular'])).toThrowError(RangeError); }); it('returns identity for equirectangular', () => { // fc.assert( // fc.property( // fc.tuple( // fc.float().filter((c) => -180 <= c && c <= 180), // fc.float().filter((c) => -180 <= c && c <= 180), // ), // (coords) => { // expect(orbisCore.project(coords, 'Equirectangular')).toEqual(coords); // }, // ), // ); [ [0, 0] as [number, number], [45, 45] as [number, number], [90, 90] as [number, number], ] .forEach((coords) => { expect(orbisCore.project(coords, ['Equirectangular'])).toEqual(coords); }); }); it('returns coords for other projections', () => { // fc.assert( // fc.property( // fc.tuple( // fc.float().filter((c) => -180 <= c && c <= 180), // fc.float().filter((c) => -180 <= c && c <= 180), // ), // (coords) => { // expect(orbisCore.project(coords, 'Equirectangular')).toEqual(coords); // }, // ), // ); [ [0, 0] as [number, number], [45, 45] as [number, number], [90, 90] as [number, number], ] .forEach((coords) => { expect(orbisCore.project(coords, ['Mercator'])).toEqual([ expect.any(Number), expect.any(Number), ]); }); }); }); });