Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TIL-EBP committed Nov 25, 2024
1 parent 4ebffc0 commit 6e0eae2
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 28 deletions.
4 changes: 2 additions & 2 deletions ui/src/elements/ngm-cam-configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import './ngm-minimap';
import {CoordinateWithCrs} from './ngm-cam-coordinates';

export type LockType = '' | 'elevation' | 'angle' | 'pitch' | 'move';
const ABSOLUTE_ELEVATION_MIN = 30000;
const ABSOLUTE_ELEVATION_MAX = 700000;
export const ABSOLUTE_ELEVATION_MIN = 30000;
export const ABSOLUTE_ELEVATION_MAX = 700000;
/*
* Convert cartographic height (between -30'000m and +300'000) to input value (between 0 and 1)
* The input value between 0 to 0.5 is mapped to the height between -30'000m and 0m
Expand Down
57 changes: 31 additions & 26 deletions ui/src/test/ngm-cam-configuration.test.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
import assert from 'assert';
import {round} from './utils';

import {heightToValue, valueToHeight} from '../elements/ngm-cam-configuration';

describe('ngm-cam-configuration', () => {
describe('heightToValue', () => {
it('should return value from height', () => {
assert.equal(round(heightToValue(300000)), 1);
assert.equal(round(heightToValue(150000)), 0.75);
assert.equal(round(heightToValue(0)), 0.5);
assert.equal(round(heightToValue(-18000)), 0.2);
assert.equal(round(heightToValue(-30000)), 0);
});
});

describe('valueToHeight', () => {
it('should return height from value', () => {
assert.equal(round(valueToHeight(1)), 300000);
assert.equal(round(valueToHeight(0.75)), 150000);
assert.equal(round(valueToHeight(0.5)), 0);
assert.equal(round(valueToHeight(0.2)), -18000);
assert.equal(round(valueToHeight(0)), -30000);
});
});
});
import assert from 'assert';
import {round} from './utils';

import {
ABSOLUTE_ELEVATION_MAX,
ABSOLUTE_ELEVATION_MIN,
heightToValue,
valueToHeight
} from '../elements/ngm-cam-configuration';

describe('ngm-cam-configuration', () => {
describe('heightToValue', () => {
it('should return value from height', () => {
assert.equal(round(heightToValue(ABSOLUTE_ELEVATION_MAX)), 1);
assert.equal(round(heightToValue(ABSOLUTE_ELEVATION_MAX / 2)), 0.75);
assert.equal(round(heightToValue(0)), 0.5);
assert.equal(round(heightToValue(-ABSOLUTE_ELEVATION_MIN * 0.6)), 0.2);
assert.equal(round(heightToValue(-ABSOLUTE_ELEVATION_MIN)), 0);
});
});

describe('valueToHeight', () => {
it('should return height from value', () => {
assert.equal(round(valueToHeight(1)), ABSOLUTE_ELEVATION_MAX);
assert.equal(round(valueToHeight(0.75)), ABSOLUTE_ELEVATION_MAX / 2);
assert.equal(round(valueToHeight(0.5)), 0);
assert.equal(round(valueToHeight(0.2)), -ABSOLUTE_ELEVATION_MIN * 0.6);
assert.equal(round(valueToHeight(0)), -ABSOLUTE_ELEVATION_MIN);
});
});
});

0 comments on commit 6e0eae2

Please sign in to comment.