Skip to content

Commit

Permalink
test: ✅ add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thkruz committed Sep 6, 2023
1 parent 96792e9 commit 27ed272
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 4 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CI

on: [push, pull_request]
on: [pull_request]

jobs:
build:
Expand All @@ -19,7 +19,7 @@ jobs:
- name: Load Node.js latest
uses: actions/setup-node@v2-beta
with:
node-version: "17.x"
node-version: '17.x'

- name: Install all dependencies
run: npm install
Expand All @@ -38,7 +38,7 @@ jobs:
- name: Use Node.js latest
uses: actions/setup-node@v2-beta
with:
node-version: "17.x"
node-version: '17.x'

- name: Get cached modules
uses: actions/cache@v2
Expand All @@ -61,7 +61,7 @@ jobs:
- name: Use Node.js latest
uses: actions/setup-node@v2-beta
with:
node-version: "17.x"
node-version: '17.x'

- name: Get cached modules
uses: actions/cache@v2
Expand Down
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"imports-loader": "^4.0.1",
"jest": "^28.1.3",
"node-fetch": "^2.6.7",
"opener": "^1.5.2",
"prettier": "^2.8.8",
"prettier-plugin-organize-imports": "^3.2.3",
"ts-node": "^10.9.1",
Expand Down
13 changes: 13 additions & 0 deletions test/objects/__snapshots__/star.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Basic Star functionality should be able to get ECI coordinates 1`] = `255314.47433812887`;

exports[`Basic Star functionality should be able to get ECI coordinates 2`] = `5732.535422340079`;

exports[`Basic Star functionality should be able to get ECI coordinates 3`] = `-2.4943615850552645e-11`;

exports[`Basic Star functionality should be able to get rae coordinates 1`] = `4.71238898038469`;

exports[`Basic Star functionality should be able to get rae coordinates 2`] = `0.9966158375158686`;

exports[`Basic Star functionality should be able to get rae coordinates 3`] = `250000`;
46 changes: 46 additions & 0 deletions test/objects/star.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* @file Test Suite to verify star class work as expected
* @author Theodore Kruczek.
* @since 3.0.0
*/

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

describe('Basic Star functionality', () => {
const star = new Star({
name: 'Test',
ra: <Radians>0,
dec: <Radians>0,
});

it('should be able to get rae coordinates', () => {
const rae = star.getRae(
{
lat: <Radians>0,
lon: <Radians>0,
alt: <Kilometers>0,
},
new Date(1661400000000),
);

expect(rae.az).toMatchSnapshot();
expect(rae.el).toMatchSnapshot();
expect(rae.rng).toMatchSnapshot();
});

it('should be able to get ECI coordinates', () => {
const eci = star.getEci(
{
lat: <Radians>0,
lon: <Radians>0,
alt: <Kilometers>0,
},
new Date(1661400000000),
);

expect(eci.x).toMatchSnapshot();
expect(eci.y).toMatchSnapshot();
expect(eci.z).toMatchSnapshot();
});
});

0 comments on commit 27ed272

Please sign in to comment.