Skip to content

Commit

Permalink
test(multi.test.js): increased testing coverage of multi module
Browse files Browse the repository at this point in the history
  • Loading branch information
thkruz committed Jan 16, 2021
1 parent 5f41d12 commit e258121
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 36 deletions.
2 changes: 0 additions & 2 deletions src/ootk-multi.worker.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// eslint-disable-next-line no-undef
importScripts('./ootk-sgp4.js');

const decoderInst = new TextDecoder();
const encoderInst = new TextEncoder();

onmessage = function (m) {
const data = JSON.parse(decoderInst.decode(m.data));
Expand Down
109 changes: 109 additions & 0 deletions test/multi/multi.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import { Multi } from '@lib/ootk-multi.js';
import { Sgp4 } from '@lib/ootk-sgp4.js';

describe('test non webworker functions', () => {
test('if chunkArray works', () => {
expect(
Multi.chunkArray(
[
{ satn: '00005' },
{ satn: '00005' },
{ satn: '00005' },
{ satn: '00005' },
{ satn: '00005' },
{ satn: '00005' },
{ satn: '00005' },
{ satn: '00005' },
{ satn: '00005' },
{ satn: '00005' },
{ satn: '00005' },
],
2,
),
).toEqual([
[
{ satn: '00005' },
{ satn: '00005' },
{ satn: '00005' },
{ satn: '00005' },
{ satn: '00005' },
{ satn: '00005' },
],
[
{ satn: '00005' },
{ satn: '00005' },
{ satn: '00005' },
{ satn: '00005' },
{ satn: '00005' },
],
]);
});
test('if chunkArray2 works', () => {
expect(
Multi.chunkArray2(
[
{ satn: '00005' },
{ satn: '00005' },
{ satn: '00005' },
{ satn: '00005' },
{ satn: '00005' },
{ satn: '00005' },
{ satn: '00005' },
{ satn: '00005' },
{ satn: '00005' },
{ satn: '00005' },
{ satn: '00005' },
],
2,
),
).toEqual([
[
{ satn: '00005' },
{ satn: '00005' },
{ satn: '00005' },
{ satn: '00005' },
{ satn: '00005' },
],
[
{ satn: '00005' },
{ satn: '00005' },
{ satn: '00005' },
{ satn: '00005' },
{ satn: '00005' },
],
[{ satn: '00005' }],
]);
});
});

describe.skip('check that Pool class generates web workers', () => {
test('if webworkers return message', () => {
const multi = new Multi(8);
let m = null;
(async () => {
let x = 0;
let propTime = -1440;

const line1 = '1 00005U 58002B 00179.78495062 .00000023 00000-0 00098-0 0 4753';
const line2 = '2 00005 34.2682 348.7242 1859667 331.7664 19.3264 10.82419157413667';
const satrec = Sgp4.createSatrec(line1, line2, 'wgs72', 'i');

const times = [];
const satrecs = [];

while (propTime <= 1440) {
times.push(propTime);
propTime += 20;
}

while (x < 1000) {
satrecs.push(satrec);
x++;
}

m = await multi.propagate(satrecs, times);
})();

expect(m).toEqual(1);
});
});
34 changes: 0 additions & 34 deletions test/pool/pool.test.js

This file was deleted.

0 comments on commit e258121

Please sign in to comment.