Skip to content

Commit 6e0eae2

Browse files
committed
fix tests
1 parent 4ebffc0 commit 6e0eae2

File tree

2 files changed

+33
-28
lines changed

2 files changed

+33
-28
lines changed

ui/src/elements/ngm-cam-configuration.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ import './ngm-minimap';
2828
import {CoordinateWithCrs} from './ngm-cam-coordinates';
2929

3030
export type LockType = '' | 'elevation' | 'angle' | 'pitch' | 'move';
31-
const ABSOLUTE_ELEVATION_MIN = 30000;
32-
const ABSOLUTE_ELEVATION_MAX = 700000;
31+
export const ABSOLUTE_ELEVATION_MIN = 30000;
32+
export const ABSOLUTE_ELEVATION_MAX = 700000;
3333
/*
3434
* Convert cartographic height (between -30'000m and +300'000) to input value (between 0 and 1)
3535
* The input value between 0 to 0.5 is mapped to the height between -30'000m and 0m
Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
1-
import assert from 'assert';
2-
import {round} from './utils';
3-
4-
import {heightToValue, valueToHeight} from '../elements/ngm-cam-configuration';
5-
6-
describe('ngm-cam-configuration', () => {
7-
describe('heightToValue', () => {
8-
it('should return value from height', () => {
9-
assert.equal(round(heightToValue(300000)), 1);
10-
assert.equal(round(heightToValue(150000)), 0.75);
11-
assert.equal(round(heightToValue(0)), 0.5);
12-
assert.equal(round(heightToValue(-18000)), 0.2);
13-
assert.equal(round(heightToValue(-30000)), 0);
14-
});
15-
});
16-
17-
describe('valueToHeight', () => {
18-
it('should return height from value', () => {
19-
assert.equal(round(valueToHeight(1)), 300000);
20-
assert.equal(round(valueToHeight(0.75)), 150000);
21-
assert.equal(round(valueToHeight(0.5)), 0);
22-
assert.equal(round(valueToHeight(0.2)), -18000);
23-
assert.equal(round(valueToHeight(0)), -30000);
24-
});
25-
});
26-
});
1+
import assert from 'assert';
2+
import {round} from './utils';
3+
4+
import {
5+
ABSOLUTE_ELEVATION_MAX,
6+
ABSOLUTE_ELEVATION_MIN,
7+
heightToValue,
8+
valueToHeight
9+
} from '../elements/ngm-cam-configuration';
10+
11+
describe('ngm-cam-configuration', () => {
12+
describe('heightToValue', () => {
13+
it('should return value from height', () => {
14+
assert.equal(round(heightToValue(ABSOLUTE_ELEVATION_MAX)), 1);
15+
assert.equal(round(heightToValue(ABSOLUTE_ELEVATION_MAX / 2)), 0.75);
16+
assert.equal(round(heightToValue(0)), 0.5);
17+
assert.equal(round(heightToValue(-ABSOLUTE_ELEVATION_MIN * 0.6)), 0.2);
18+
assert.equal(round(heightToValue(-ABSOLUTE_ELEVATION_MIN)), 0);
19+
});
20+
});
21+
22+
describe('valueToHeight', () => {
23+
it('should return height from value', () => {
24+
assert.equal(round(valueToHeight(1)), ABSOLUTE_ELEVATION_MAX);
25+
assert.equal(round(valueToHeight(0.75)), ABSOLUTE_ELEVATION_MAX / 2);
26+
assert.equal(round(valueToHeight(0.5)), 0);
27+
assert.equal(round(valueToHeight(0.2)), -ABSOLUTE_ELEVATION_MIN * 0.6);
28+
assert.equal(round(valueToHeight(0)), -ABSOLUTE_ELEVATION_MIN);
29+
});
30+
});
31+
});

0 commit comments

Comments
 (0)