Skip to content

Commit 8351f02

Browse files
committed
PB-95: Added unit tests
1 parent cca9ff7 commit 8351f02

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

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

+30-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ 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+
reprojectUnknownSrsCoordsToWGS84,
8+
flattenExtent,
9+
normalizeExtent,
10+
} from '@/utils/coordinates/coordinateUtils'
11+
import exp from 'constants'
712

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

0 commit comments

Comments
 (0)