Skip to content

Commit 1428a01

Browse files
committed
PB-95: Added unit tests
1 parent cca9ff7 commit 1428a01

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

src/utils/coordinates/__test__/coordinateUtils.spec.js

+29-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ import proj4 from 'proj4'
33
import { describe, it } from 'vitest'
44

55
import { LV03, LV95, WEBMERCATOR, WGS84 } from '@/utils/coordinates/coordinateSystems'
6-
import { reprojectUnknownSrsCoordsToWGS84 } from '@/utils/coordinates/coordinateUtils'
6+
import {
7+
flattenExtent,
8+
normalizeExtent,
9+
reprojectUnknownSrsCoordsToWGS84,
10+
} from '@/utils/coordinates/coordinateUtils'
711

812
describe('Unit test functions from coordinateUtils.js', () => {
913
describe('reprojectUnknownSrsCoordsToWGS84(x,y)', () => {
@@ -74,5 +78,29 @@ describe('Unit test functions from coordinateUtils.js', () => {
7478
coordinatesWGS84
7579
)
7680
})
81+
it('normalize an extent', () => {
82+
const flatExtent = [1, 2, 3, 4]
83+
const result = normalizeExtent(flatExtent)
84+
expect(result).to.have.length(2)
85+
expect(result[0]).to.have.length(2)
86+
expect(result[1]).to.have.length(2)
87+
expect(result[0][0]).to.equal(1)
88+
expect(result[0][1]).to.equal(2)
89+
expect(result[1][0]).to.equal(3)
90+
expect(result[1][1]).to.equal(4)
91+
92+
expect(normalizeExtent(result)).to.deep.equal(result)
93+
})
94+
it('flattern an extent', () => {
95+
const normalizedExtent = [
96+
[1, 2],
97+
[3, 4],
98+
]
99+
const flatExtent = flattenExtent(normalizedExtent)
100+
expect(flatExtent).to.have.length(4)
101+
expect(flatExtent).to.deep.equal([1, 2, 3, 4])
102+
103+
expect(flattenExtent(flatExtent)).to.deep.equal([1, 2, 3, 4])
104+
})
77105
})
78106
})

0 commit comments

Comments
 (0)