// import * as fc from 'fast-check'; import { describe, it, expect } from 'vitest'; import * as orbisCore from '../src'; describe('orbis-core', () => { describe('projectPoint', () => { it('throws error for invalid coordinates', () => { expect(() => orbisCore.projectPoint([-181, 90], ['Equirectangular'])).toThrowError(RangeError); expect(() => orbisCore.projectPoint([181, 90], ['Equirectangular'])).toThrowError(RangeError); expect(() => orbisCore.projectPoint([-180, 91], ['Equirectangular'])).toThrowError(RangeError); expect(() => orbisCore.projectPoint([-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.projectPoint(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.projectPoint(coords, ['Mercator'])).toEqual([ expect.any(Number), expect.any(Number), ]); }); }); }); });