Skip to content

Commit

Permalink
fix: ✅ fix test paths
Browse files Browse the repository at this point in the history
  • Loading branch information
thkruz committed Jan 7, 2024
1 parent 9893a6a commit b784f3e
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 40 deletions.
4 changes: 2 additions & 2 deletions test/objects/star.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* @since 3.0.0
*/

import { Star } from '@src/objects';
import { Degrees, Kilometers, Radians } from '@src/ootk';
import { Star } from '../../lib/objects';
import { Degrees, Kilometers, Radians } from '../../lib/ootk';

describe('Basic Star functionality', () => {
const star = new Star({
Expand Down
14 changes: 7 additions & 7 deletions test/sat/sat.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @since 1.2.0
*/

import { Sat } from '../../lib/ootk';
import { Satellite } from '../../lib/ootk';
import { RAD2DEG } from '../../lib/utils/constants';

const dateObj = new Date(1661400000000);
Expand All @@ -14,7 +14,7 @@ const tle2 = '2 25544 51.6415 161.8339 0005168 35.9781 54.7009 15.50067047350

describe('Basic Satellite functionality', () => {
it('should create a new Sat object', () => {
const sat = new Sat({ name: 'Test', tle1, tle2 });
const sat = new Satellite({ name: 'Test', tle1, tle2 });

expect(sat).toBeDefined();
expect(sat.inclination).toBe(51.6415);
Expand All @@ -23,15 +23,15 @@ describe('Basic Satellite functionality', () => {
});

it('should allow chaining', () => {
const eci = new Sat({ name: 'Test', tle1, tle2 }).propagateTo(dateObj).getEci().position;
const eci = new Satellite({ name: 'Test', tle1, tle2 }).propagateTo(dateObj).getEci().position;

expect(eci.x).toBeCloseTo(6512.640035319078);
expect(eci.y).toBeCloseTo(-1545.524934684146);
expect(eci.z).toBeCloseTo(-1195.219347050479);
});

it('should allow getting eci coordinates', () => {
const sat = new Sat({ name: 'Test', tle1, tle2 });
const sat = new Satellite({ name: 'Test', tle1, tle2 });

const eci = sat.getEci(dateObj).position;

Expand All @@ -41,7 +41,7 @@ describe('Basic Satellite functionality', () => {
});

it('should allow getting ecf coordinates', () => {
const sat = new Sat({ name: 'Test', tle1, tle2 });
const sat = new Satellite({ name: 'Test', tle1, tle2 });

const eci = sat.getEcf(dateObj);

Expand All @@ -51,7 +51,7 @@ describe('Basic Satellite functionality', () => {
});

it('should allow getting lla coordinates', () => {
const sat = new Sat({ name: 'Test', tle1, tle2 });
const sat = new Satellite({ name: 'Test', tle1, tle2 });

const eci = sat.lla(dateObj);

Expand All @@ -61,7 +61,7 @@ describe('Basic Satellite functionality', () => {
});

it('should be able to get the orbital period', () => {
const sat = new Sat({ name: 'Test', tle1, tle2 });
const sat = new Satellite({ name: 'Test', tle1, tle2 });

expect(sat.period).toBeCloseTo(92.89920734635164);
});
Expand Down
4 changes: 2 additions & 2 deletions test/sat/sensor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
* @since 1.2.0
*/

import { Degrees, Kilometers, Sat, Sensor, SpaceObjectType, TleLine1, TleLine2 } from '../../src/ootk';
import { Degrees, Kilometers, Satellite, Sensor, SpaceObjectType, TleLine1, TleLine2 } from '../../lib/ootk';

const dateObj = new Date(1661400000000);

const tle1 = '1 25544U 98067A 22203.46960946 .00003068 00000+0 61583-4 0 9996' as TleLine1;
const tle2 = '2 25544 51.6415 161.8339 0005168 35.9781 54.7009 15.50067047350657' as TleLine2;

describe('Basic Sensor functionality', () => {
const sat = new Sat({ name: 'Test', tle1, tle2 });
const sat = new Satellite({ name: 'Test', tle1, tle2 });

it('should be able to get rae coordinates', () => {
const sensor = new Sensor({
Expand Down
3 changes: 1 addition & 2 deletions test/sgp4/legacy/ext.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
* @since 0.2.0
*/

import { Sgp4 } from '@lib/ootk';
import { compareVectors } from '@test/lib/compareVectors';
import { Sgp4 } from '../../../lib/ootk';

describe('Julian date / time', () => {
// Use number of milliseconds since epoch instead of local year, month, day, etc for consistency across machines
Expand Down
2 changes: 1 addition & 1 deletion test/sgp4/legacy/initl.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @since 0.2.0
*/

import { Sgp4 } from '@lib/ootk'; // eslint-disable-line
import { Sgp4 } from '../../../lib/ootk'; // eslint-disable-line

// wgs84 constants
const mu = 398600.8; // in km3 / s2
Expand Down
2 changes: 1 addition & 1 deletion test/sgp4/legacy/io.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @since 0.2.0
*/

import { Sgp4 } from '@lib/ootk'; // eslint-disable-line
import { Sgp4 } from '../../../src/ootk'; // eslint-disable-line
import badTleData from './io.json';

describe('Twoline', () => {
Expand Down
6 changes: 3 additions & 3 deletions test/sgp4/rsr/rsr3.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
* sgp4Data is from https://www.celestrak.com/publications/AIAA/2006-6753/AIAA-2006-6753-Rev1.pdf
* Only using the first and last state vectors for verification
*/
import { Sgp4 } from '@lib/ootk';
import { compareVectors } from '@test/lib/compareVectors';
import sgp4Data from './rsr3.json';
import { Sgp4 } from '../../../lib/ootk';
import { compareVectors } from '../../lib/compareVectors';
import sgp4FailData from './rsr3-fail.json';
import sgp4Data from './rsr3.json';

describe('Verification TLE Data in Appendix D of Revisiting Spacetrack Report #3: Rev 1', () => {
sgp4Data.forEach((sgp4DataItem) => {
Expand Down
2 changes: 1 addition & 1 deletion test/sgp4/sgp4-full-cov.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @since 0.2.0
*/

import { Sgp4 } from '@lib/ootk';
import { Sgp4 } from '../../lib/ootk';
import sgp4FailData from './sgp4-full-cov-fail.json';
import sgp4Data from './sgp4-full-cov.json';

Expand Down
2 changes: 1 addition & 1 deletion test/tle/tle.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @since 1.1.0
*/

import { Tle } from '@lib/ootk';
import { Tle } from '../../lib/ootk';
import tleData from './tle.json';

describe('Valid TLEs', () => {
Expand Down
48 changes: 30 additions & 18 deletions test/transforms/transforms.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
/**
* @file Tests from Transforms.js to ensure compatibility
* @file Tests from js to ensure compatibility
* @since 0.2.0
*/

import { Transforms } from '../../lib/ootk';
import {
ecf2eci,
ecf2rae,
eci2ecf,
eci2lla,
getDegLat,
getDegLon,
getRadLat,
getRadLon,
lla2ecf,
rae2ecf,
rae2sez,
} from '../../lib/ootk';
import { RAD2DEG } from '../../lib/utils/constants';
import transformData from './transforms.json';

Expand All @@ -24,25 +36,25 @@ describe('Latitude & longitude conversions', () => {

validLatitudes.forEach((item) => {
it(`convert valid latitude value (${item.radians} radians) to degrees`, () => {
expect(Transforms.getDegLat(item.radians)).toBeCloseTo(item.degrees, numDigits);
expect(getDegLat(item.radians)).toBeCloseTo(item.degrees, numDigits);
});
it(`convert valid latitude value (${item.degrees} degrees) to radians`, () => {
expect(Transforms.getRadLat(item.degrees)).toBeCloseTo(item.radians, numDigits);
expect(getRadLat(item.degrees)).toBeCloseTo(item.radians, numDigits);
});
});

validLongitudes.forEach((item) => {
it(`convert valid longitude value (${item.radians} radians) to degrees`, () => {
expect(Transforms.getDegLon(item.radians)).toBeCloseTo(item.degrees, numDigits);
expect(getDegLon(item.radians)).toBeCloseTo(item.degrees, numDigits);
});
it(`convert valid longitude value (${item.degrees} degrees) to radians`, () => {
expect(Transforms.getRadLon(item.degrees)).toBeCloseTo(item.radians, numDigits);
expect(getRadLon(item.degrees)).toBeCloseTo(item.radians, numDigits);
});
});

validGeodeticToEcf.forEach((item) => {
it('convert valid LLA coordinates to ECF', () => {
const ecfCoordinates = Transforms.lla2ecf(item.lla);
const ecfCoordinates = lla2ecf(item.lla);

expect(ecfCoordinates.x).toBeCloseTo(item.ecf.x);
expect(ecfCoordinates.y).toBeCloseTo(item.ecf.y);
Expand All @@ -52,7 +64,7 @@ describe('Latitude & longitude conversions', () => {

validEciToGeodetic.forEach((item) => {
it('convert valid ECI coordinates to LLA', () => {
const llaCoordinates = Transforms.eci2lla(item.eci, item.gmst);
const llaCoordinates = eci2lla(item.eci, item.gmst);

expect(llaCoordinates.lon).toBeCloseTo(item.lla.lon * RAD2DEG);
expect(llaCoordinates.lat).toBeCloseTo(item.lla.lat * RAD2DEG);
Expand All @@ -62,7 +74,7 @@ describe('Latitude & longitude conversions', () => {

validEciToEcf.forEach((item) => {
it('convert valid ECI coordinates to ECF', () => {
const ecfCoordinates = Transforms.eci2ecf(item.eci, item.gmst);
const ecfCoordinates = eci2ecf(item.eci, item.gmst);

expect(ecfCoordinates.x).toBeCloseTo(item.ecf.x);
expect(ecfCoordinates.y).toBeCloseTo(item.ecf.y);
Expand All @@ -72,7 +84,7 @@ describe('Latitude & longitude conversions', () => {

validEcfToEci.forEach((item) => {
it('convert valid ECF coordinates to ECI', () => {
const eciCoordinates = Transforms.ecf2eci(item.ecf, item.gmst);
const eciCoordinates = ecf2eci(item.ecf, item.gmst);

expect(eciCoordinates.x).toBeCloseTo(item.eci.x);
expect(eciCoordinates.y).toBeCloseTo(item.eci.y);
Expand All @@ -82,7 +94,7 @@ describe('Latitude & longitude conversions', () => {

validEcfToLookangles.forEach((item) => {
it('convert valid ECF coordinates to RAE', () => {
const raeCoordinates = Transforms.ecf2rae(item.lla, item.satelliteEcf);
const raeCoordinates = ecf2rae(item.lla, item.satelliteEcf);

expect(raeCoordinates.rng).toBeCloseTo(item.rae.rng, 0);
expect(raeCoordinates.az).toBeCloseTo(item.rae.az * RAD2DEG, 1);
Expand All @@ -92,27 +104,27 @@ describe('Latitude & longitude conversions', () => {

invalidLatitudes.forEach((item) => {
it(`convert invalid latitude value (${item.radians} radians) to degrees`, () => {
expect(() => Transforms.getDegLat(item.radians)).toThrowError(RangeError);
expect(() => getDegLat(item.radians)).toThrowError(RangeError);
});
it(`convert invalid latitude value (${item.degrees} degrees) to radians`, () => {
expect(() => Transforms.getRadLat(item.degrees)).toThrowError(RangeError);
expect(() => getRadLat(item.degrees)).toThrowError(RangeError);
});
});

invalidLongitudes.forEach((item) => {
it(`convert invalid longitude value (${item.radians} radians) to degrees`, () => {
expect(() => Transforms.getDegLon(item.radians)).toThrowError(RangeError);
expect(() => getDegLon(item.radians)).toThrowError(RangeError);
});
it(`convert invalid longitude value (${item.degrees} degrees) to radians`, () => {
expect(() => Transforms.getRadLon(item.degrees)).toThrowError(RangeError);
expect(() => getRadLon(item.degrees)).toThrowError(RangeError);
});
});
});

describe('Rae2Sez', () => {
it('should convert valid RAE coordinates to SEZ', () => {
const { rae, sez } = transformData.validRae2Sez[0];
const sezCoordinates = Transforms.rae2sez(rae);
const sezCoordinates = rae2sez(rae);

expect(sezCoordinates.s).toBeCloseTo(sez.s);
expect(sezCoordinates.e).toBeCloseTo(sez.e);
Expand All @@ -133,12 +145,12 @@ describe('Rae2Ecf', () => {
lat: 0,
alt: 0,
};
const rae = Transforms.ecf2rae(lla, ecf);
const rae = ecf2rae(lla, ecf);

// eslint-disable-next-line no-console
console.warn(rae);

const ecfCoordinates = Transforms.rae2ecf(rae, lla);
const ecfCoordinates = rae2ecf(rae, lla);

expect(ecfCoordinates.x).toBeCloseTo(ecf.x);
expect(ecfCoordinates.y).toBeCloseTo(ecf.y);
Expand Down
4 changes: 2 additions & 2 deletions test/utils/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* @since 1.0.0-alpha3
*/

import { Utils } from '@lib/ootk'; // eslint-disable-line
import { getDayOfYear } from '@lib/utils/functions';
import { Utils } from '../../lib/ootk'; // eslint-disable-line
import { getDayOfYear } from '../../lib/utils/functions';

const numDigits = 8;

Expand Down

0 comments on commit b784f3e

Please sign in to comment.