diff --git a/test/body/Celestial.test.ts b/test/body/Celestial.test.ts index 3b29f30..3d69a24 100644 --- a/test/body/Celestial.test.ts +++ b/test/body/Celestial.test.ts @@ -1,6 +1,5 @@ import { Degrees, Radians } from './../../src/types/types'; import { Celestial } from './../../src/body/Celestial'; -import { mockExampleDate } from '../lib/mockData'; describe('Celestial', () => { /* @@ -8,6 +7,7 @@ describe('Celestial', () => { * latitude, longitude, right ascension, and declination. */ it('should calculate the azimuth and elevation when given valid inputs', () => { + const mockExampleDate = new Date(1705109326817); const lat = 37.7749 as Degrees; // latitude of San Francisco const lon = -122.4194 as Degrees; // longitude of San Francisco const ra = 1.3963 as Radians; // right ascension of a celestial object diff --git a/test/body/Earth.test.ts b/test/body/Earth.test.ts index dd87561..e7b60f8 100644 --- a/test/body/Earth.test.ts +++ b/test/body/Earth.test.ts @@ -1,7 +1,14 @@ import { Earth, EpochUTC, Vector3D } from '../../src/main'; -import { mockExampleDate } from '../lib/mockData'; describe('Earth', () => { + let exampleDate = new Date(1705109326817); + + beforeEach(() => { + const mockExampleDate = new Date(1705109326817); + + exampleDate = new Date(mockExampleDate.getTime()); + }); + // can calculate mean motion from semimajor axis it('should calculate mean motion when given a semimajor axis', () => { const semimajorAxis = 7000; // km @@ -12,7 +19,7 @@ describe('Earth', () => { // can calculate precession angles from epoch it('should calculate precession angles when given an epoch', () => { - const epoch = EpochUTC.fromDateTime(mockExampleDate); + const epoch = EpochUTC.fromDateTime(exampleDate); const precessionAngles = Earth.precession(epoch); expect(precessionAngles.zeta).toMatchSnapshot(); @@ -22,7 +29,7 @@ describe('Earth', () => { // can calculate nutation angles from epoch it('should calculate nutation angles when given an epoch', () => { - const epoch = EpochUTC.fromDateTime(mockExampleDate); + const epoch = EpochUTC.fromDateTime(exampleDate); const nutationAngles = Earth.nutation(epoch); expect(nutationAngles.dPsi).toMatchSnapshot(); @@ -66,7 +73,7 @@ describe('Earth', () => { }); // can calculate Earth's diameter from satellite position - it("should calculate Earth's diameter from satellite position", () => { + it('should calculate Earth\'s diameter from satellite position', () => { const satPos = new Vector3D(1000, 1000, 1000); const diameter = Earth.diameter(satPos); @@ -75,7 +82,7 @@ describe('Earth', () => { // can handle epoch before 1900 when calculating precession angles it('should handle epoch before 1900 when calculating precession angles', () => { - const epoch = EpochUTC.fromDateTime(mockExampleDate); + const epoch = EpochUTC.fromDateTime(exampleDate); const precessionAngles = Earth.precession(epoch); expect(precessionAngles.zeta).toMatchSnapshot(); @@ -83,7 +90,7 @@ describe('Earth', () => { // can handle epoch after 2150 when calculating precession angles it('should handle epoch after 2150 when calculating precession angles', () => { - const epoch = EpochUTC.fromDateTime(mockExampleDate); + const epoch = EpochUTC.fromDateTime(exampleDate); const precessionAngles = Earth.precession(epoch); expect(precessionAngles.zeta).not.toBeNaN(); @@ -92,7 +99,7 @@ describe('Earth', () => { // can handle epoch before 1900 when calculating nutation angles it('should handle epoch before 1900 when calculating nutation angles', () => { - const epoch = EpochUTC.fromDateTime(mockExampleDate); + const epoch = EpochUTC.fromDateTime(exampleDate); const nutationAngles = Earth.nutation(epoch); expect(nutationAngles.dPsi).not.toBeNaN(); @@ -101,7 +108,7 @@ describe('Earth', () => { // can handle epoch after 2150 when calculating nutation angles it('should handle epoch after 2150 when calculating nutation angles', () => { - const epoch = EpochUTC.fromDateTime(mockExampleDate); + const epoch = EpochUTC.fromDateTime(exampleDate); const nutationAngles = Earth.nutation(epoch); expect(nutationAngles.dPsi).not.toBeNaN(); diff --git a/test/body/Moon.test.ts b/test/body/Moon.test.ts index 45aa683..0a8fad8 100644 --- a/test/body/Moon.test.ts +++ b/test/body/Moon.test.ts @@ -1,10 +1,11 @@ import { Degrees, EpochUTC, Moon, Vector3D } from '../../src/main'; -import { mockExampleDate } from '../lib/mockData'; describe('Moon', () => { let exampleDate: Date; beforeEach(() => { + const mockExampleDate = new Date(1705109326817); + exampleDate = new Date(mockExampleDate.getTime()); }); diff --git a/test/body/Sun.test.ts b/test/body/Sun.test.ts index ec909fd..9ebd93b 100644 --- a/test/body/Sun.test.ts +++ b/test/body/Sun.test.ts @@ -1,10 +1,11 @@ import { Degrees, EpochUTC, Kilometers, Meters, Sun, Vector3D } from '../../src/main'; -import { mockExampleDate } from '../lib/mockData'; describe('Sun', () => { let exampleDate: Date; beforeEach(() => { + const mockExampleDate = new Date(1705109326817); + exampleDate = new Date(mockExampleDate.getTime()); }); diff --git a/test/body/__snapshots__/Moon.test.ts.snap b/test/body/__snapshots__/Moon.test.ts.snap index ac41586..1c84181 100644 --- a/test/body/__snapshots__/Moon.test.ts.snap +++ b/test/body/__snapshots__/Moon.test.ts.snap @@ -77,28 +77,6 @@ Object { } `; -exports[`Moon should return an object with 'rise', 'set', 'ye', 'alwaysUp', 'alwaysDown', and 'highest' properties 1`] = ` -Object { - "alwaysDown": false, - "alwaysUp": false, - "highest": 2024-01-12T21:42:31.618Z, - "rise": 2024-01-12T16:43:59.167Z, - "set": 2024-01-13T02:41:04.069Z, - "ye": null, -} -`; - -exports[`Moon should return an object with 'rise', 'set', 'ye', 'alwaysUp', 'alwaysDown', and 'highest' properties 2`] = ` -Object { - "alwaysDown": false, - "alwaysUp": false, - "highest": 2024-01-12T21:42:31.618Z, - "rise": 2024-01-12T16:43:59.167Z, - "set": 2024-01-13T02:41:04.069Z, - "ye": null, -} -`; - exports[`Moon should return with 'rise', 'set', 'ye', 'alwaysUp', 'alwaysDown', 'highest' properties 1`] = ` Object { "alwaysDown": false, diff --git a/test/body/__snapshots__/Sun.test.ts.snap b/test/body/__snapshots__/Sun.test.ts.snap index 889f88d..df0710a 100644 --- a/test/body/__snapshots__/Sun.test.ts.snap +++ b/test/body/__snapshots__/Sun.test.ts.snap @@ -45,9 +45,9 @@ exports[`Sun should return the number of days since January 1, 2000, for a given exports[`Sun should return the same apparent position result given the same time and position 1`] = ` Vector3D { - "x": 54242939.78872876, - "y": -125479049.84825934, - "z": -54393990.21165644, + "x": 55101974.26909711, + "y": -125165869.77224815, + "z": -54258234.63367154, } `; diff --git a/test/coordinate/ITRF.test.ts b/test/coordinate/ITRF.test.ts index faf1d64..854fe08 100644 --- a/test/coordinate/ITRF.test.ts +++ b/test/coordinate/ITRF.test.ts @@ -1,12 +1,15 @@ -import { mockExampleDate } from '../lib/mockData'; import { Earth, EpochUTC, ITRF, Kilometers, Vector3D } from './../../src/main'; // Generated by CodiumAI describe('ITRF', () => { let epochUtc: EpochUTC; + let exampleDate: Date; let itrf: ITRF; beforeEach(() => { + const mockExampleDate = new Date(1705109326817); + + exampleDate = new Date(mockExampleDate.getTime()); epochUtc = EpochUTC.fromDateTime(mockExampleDate); itrf = new ITRF( epochUtc, @@ -191,8 +194,8 @@ describe('ITRF', () => { it('should handle position at different epochs', () => { const position = new Vector3D(1000 as Kilometers, 2000 as Kilometers, 3000 as Kilometers); const velocity = new Vector3D(10 as Kilometers, 20 as Kilometers, 30 as Kilometers); - const epoch1 = EpochUTC.fromDateTime(mockExampleDate); - const epoch2 = EpochUTC.fromDateTime(new Date(mockExampleDate.getTime() + 1000)); + const epoch1 = EpochUTC.fromDateTime(exampleDate); + const epoch2 = EpochUTC.fromDateTime(new Date(exampleDate.getTime() + 1000)); const itrf1 = new ITRF(epoch1, position, velocity); const itrf2 = new ITRF(epoch2, position, velocity); diff --git a/test/coordinate/J2000.test.ts b/test/coordinate/J2000.test.ts index 7c72dd2..bcc4040 100644 --- a/test/coordinate/J2000.test.ts +++ b/test/coordinate/J2000.test.ts @@ -1,10 +1,10 @@ // Generated by CodiumAI import { EpochUTC, ClassicalElements, Kilometers, Radians, J2000, Vector3D } from '../../src/main'; -import { mockExampleDate } from '../lib/mockData'; describe('J2000', () => { - const epoch = EpochUTC.fromDateTime(mockExampleDate); + const exampleDate = new Date(1705109326817); + const epoch = EpochUTC.fromDateTime(exampleDate); // can be created from classical elements it('should create a J2000 coordinate from classical elements', () => { diff --git a/test/coordinate/TEME.test.ts b/test/coordinate/TEME.test.ts index d7a199d..8ba1b8e 100644 --- a/test/coordinate/TEME.test.ts +++ b/test/coordinate/TEME.test.ts @@ -1,4 +1,3 @@ -import { mockExampleDate } from '../lib/mockData'; import { ClassicalElements, EpochUTC, J2000, Kilometers, Radians, TEME, Vector3D } from './../../src/main'; describe('TEME', () => { let stateVector: TEME; @@ -27,7 +26,8 @@ describe('TEME', () => { // fromClassicalElements it('should create a TEME coordinate from classical orbital elements', () => { - const epoch = EpochUTC.fromDateTime(mockExampleDate); + const exampleDate = new Date(1705109326817); + const epoch = EpochUTC.fromDateTime(exampleDate); const elements = new ClassicalElements({ epoch, semimajorAxis: 6943.547853722985 as Kilometers, diff --git a/test/coordinate/Tle.test.ts b/test/coordinate/Tle.test.ts index 258cc81..b911503 100644 --- a/test/coordinate/Tle.test.ts +++ b/test/coordinate/Tle.test.ts @@ -1,14 +1,16 @@ -import { mockExampleDate } from '../lib/mockData'; import { ClassicalElements, EpochUTC, Kilometers, Radians, Tle, TleLine1, TleLine2 } from '../../src/main'; describe('Tle', () => { let tle: Tle; + let exampleDate: Date; beforeEach(() => { // Sample TLE const tle1 = '1 56006U 23042W 24012.45049317 .00000296 00000-0 36967-4 0 9992' as TleLine1; const tle2 = '2 56006 143.0043 13.3620 0001137 267.5965 92.4747 15.02542972 44491' as TleLine2; + const mockExampleDate = new Date(1705109326817); + exampleDate = new Date(mockExampleDate.getTime()); tle = new Tle(tle1, tle2); }); @@ -54,7 +56,7 @@ describe('Tle', () => { // propagate it('should propagate the TLE', () => { - const epoch = EpochUTC.fromDateTime(mockExampleDate); + const epoch = EpochUTC.fromDateTime(exampleDate); const propagated = tle.propagate(epoch); expect(propagated).toMatchSnapshot(); @@ -67,7 +69,7 @@ describe('Tle', () => { // fromClassicalElements it('should create a TLE from classical orbital elements', () => { - const epoch = EpochUTC.fromDateTime(mockExampleDate); + const epoch = EpochUTC.fromDateTime(exampleDate); const elements = new ClassicalElements({ epoch, semimajorAxis: 6943.547853722985 as Kilometers, diff --git a/test/lib/mockData.ts b/test/lib/mockData.ts index 48b9bc2..ffdd0d2 100644 --- a/test/lib/mockData.ts +++ b/test/lib/mockData.ts @@ -1 +1 @@ -export const mockExampleDate = new Date(1705109326817); +// Empty for now diff --git a/test/objects/GroundObject.test.ts b/test/objects/GroundObject.test.ts index 4284c91..2f7c594 100644 --- a/test/objects/GroundObject.test.ts +++ b/test/objects/GroundObject.test.ts @@ -1,11 +1,14 @@ -import { mockExampleDate } from '../lib/mockData'; import { Degrees, Geodetic, GroundObject, Kilometers, Radians } from '../../src/main'; describe('GroundObject', () => { let groundObject: GroundObject; let geodetic: Geodetic; + let exampleDate: Date; beforeEach(() => { + const mockExampleDate = new Date(1705109326817); + + exampleDate = new Date(mockExampleDate.getTime()); groundObject = new GroundObject({ lat: 0 as Degrees, lon: 0 as Degrees, @@ -40,7 +43,7 @@ describe('GroundObject', () => { }); it('should calculate eci', () => { - expect(groundObject.eci(mockExampleDate)).toMatchSnapshot(); + expect(groundObject.eci(exampleDate)).toMatchSnapshot(); }); it('should calculate llaRad', () => { diff --git a/test/objects/Satellite.test.ts b/test/objects/Satellite.test.ts index 3d7c853..6cd2416 100644 --- a/test/objects/Satellite.test.ts +++ b/test/objects/Satellite.test.ts @@ -8,7 +8,6 @@ import { TleLine1, TleLine2, } from '../../src/main'; -import { mockExampleDate } from '../lib/mockData'; const dateObj = new Date(1661400000000); @@ -71,6 +70,7 @@ describe('Basic Satellite functionality', () => { describe('Satellite', () => { let satellite: Satellite; let observer: GroundObject; + let exampleDate: Date; beforeEach(() => { const satelliteParams: SatelliteParams = { @@ -78,6 +78,9 @@ describe('Satellite', () => { tle2, }; + const mockExampleDate = new Date(1705109326817); + + exampleDate = new Date(mockExampleDate.getTime()); satellite = new Satellite(satelliteParams); observer = new GroundObject(llaObserver); }); @@ -88,42 +91,42 @@ describe('Satellite', () => { // can calculate and return RAE coordinates it('should calculate and return RAE coordinates', () => { - const rae = satellite.toRae(observer, mockExampleDate); + const rae = satellite.toRae(observer, exampleDate); expect(rae).toMatchSnapshot(); }); // can calculate and return ECI coordinates it('should calculate and return ECI coordinates', () => { - const eci = satellite.eci(mockExampleDate); + const eci = satellite.eci(exampleDate); expect(eci).toMatchSnapshot(); }); // can calculate and return ECF coordinates it('should calculate and return ECF coordinates correctly', () => { - const ecfCoordinates = satellite.ecf(mockExampleDate); + const ecfCoordinates = satellite.ecf(exampleDate); expect(ecfCoordinates).toMatchSnapshot(); }); // can calculate and return LLA coordinates it('should calculate and return LLA coordinates when given a date', () => { - const lla = satellite.lla(mockExampleDate); + const lla = satellite.lla(exampleDate); expect(lla).toMatchSnapshot(); }); // can calculate and return Geodetic coordinates it('should calculate and return Geodetic coordinates when given a date', () => { - const geodetic = satellite.toGeodetic(mockExampleDate); + const geodetic = satellite.toGeodetic(exampleDate); expect(geodetic).toMatchSnapshot(); }); // can calculate and return ITRF coordinates it('should calculate and return ITRF coordinates when called', () => { - const itrfCoordinates = satellite.toITRF(mockExampleDate); + const itrfCoordinates = satellite.toITRF(exampleDate); expect(itrfCoordinates).toMatchSnapshot(); }); @@ -135,22 +138,22 @@ describe('Satellite', () => { tle2: '2 25544 51.6442 13.1247 0008036 23.6079 336.5377 15.48861704303602' as TleLine2, }); - const ric = satellite.toRIC(referenceSatellite, mockExampleDate); + const ric = satellite.toRIC(referenceSatellite, exampleDate); expect(ric).toMatchSnapshot(); }); // can calculate and return range to an observer it('should calculate and return range to an observer', () => { - const range = satellite.range(observer, mockExampleDate); + const range = satellite.range(observer, exampleDate); expect(range).toMatchSnapshot(); }); // can calculate and return azimuth and elevation angles it('should calculate and return azimuth and elevation angles correctly', () => { - const azimuth = satellite.az(observer, mockExampleDate); - const elevation = satellite.el(observer, mockExampleDate); + const azimuth = satellite.az(observer, exampleDate); + const elevation = satellite.el(observer, exampleDate); expect(azimuth).toMatchSnapshot(); expect(elevation).toMatchSnapshot(); diff --git a/test/transforms/transforms.test.ts b/test/transforms/transforms.test.ts index b8c08d8..91832e2 100644 --- a/test/transforms/transforms.test.ts +++ b/test/transforms/transforms.test.ts @@ -1,4 +1,3 @@ -import { mockExampleDate } from '../lib/mockData'; import { RadarSensor, azel2uv, @@ -220,7 +219,8 @@ describe('Rae2Ecf', () => { lat: 0 as Radians, alt: 0 as Kilometers, }; - const { gmst } = calcGmst(mockExampleDate); + const exampleDate = new Date(1705109326817); + const { gmst } = calcGmst(exampleDate); const eciCoordinates = lla2eci(lla, gmst); expect(eciCoordinates).toMatchSnapshot(); @@ -256,7 +256,8 @@ describe('Rae2Ecf', () => { minRng: 0 as Kilometers, maxRng: 0 as Kilometers, }) as RadarSensor; - const { gmst } = calcGmst(mockExampleDate); + const exampleDate = new Date(1705109326817); + const { gmst } = calcGmst(exampleDate); const eciCoordinates = rae2eci(rae, sensor, gmst); @@ -348,7 +349,8 @@ describe('Rae2Ecf', () => { maxRng: 0 as Kilometers, }) as RadarSensor; - const raeCoordinates = eci2rae(mockExampleDate, eci, sensor); + const exampleDate = new Date(1705109326817); + const raeCoordinates = eci2rae(exampleDate, eci, sensor); expect(raeCoordinates).toMatchSnapshot(); });