|
1 | 1 | import { expect } from 'chai'
|
2 | 2 | import { describe, it } from 'vitest'
|
3 | 3 |
|
4 |
| -import { |
5 |
| - formatMeters, |
6 |
| - formatPointCoordinates, |
7 |
| - formatTime, |
8 |
| - toLv95, |
9 |
| - wrapXCoordinates, |
10 |
| -} from '@/modules/drawing/lib/drawingUtils' |
11 |
| -import { LV95, WEBMERCATOR, WGS84 } from '@/utils/coordinates/coordinateSystems' |
| 4 | +import { wrapXCoordinates } from '@/modules/drawing/lib/drawingUtils' |
| 5 | +import { WGS84 } from '@/utils/coordinates/coordinateSystems' |
12 | 6 |
|
13 | 7 | describe('Unit test functions from drawingUtils.js', () => {
|
14 |
| - describe('toLv95(coordinate, "EPSG:4326")', () => { |
15 |
| - it('reprojects points from EPSG:4326', () => { |
16 |
| - expect(LV95.isInBounds(...toLv95([6.57268, 46.51333], WGS84.epsg))).to.be.true |
17 |
| - }) |
18 |
| - it('reprojects points from EPSG:3857', () => { |
19 |
| - expect(LV95.isInBounds(...toLv95([731667, 5862995], WEBMERCATOR.epsg))).to.be.true |
20 |
| - }) |
21 |
| - it('reprojects lines', () => { |
22 |
| - const result = toLv95( |
23 |
| - [ |
24 |
| - [6.57268, 46.51333], |
25 |
| - [6.7, 46.7], |
26 |
| - ], |
27 |
| - WGS84.epsg |
28 |
| - ) |
29 |
| - expect(result).to.be.an('Array').lengthOf(2) |
30 |
| - result.forEach((coord) => { |
31 |
| - expect(LV95.isInBounds(...coord)).to.be.true |
32 |
| - }) |
33 |
| - }) |
34 |
| - it('reprojects polygons', () => { |
35 |
| - const result = toLv95( |
36 |
| - [ |
37 |
| - [6.57268, 46.51333], |
38 |
| - [6.7, 46.7], |
39 |
| - [6.9, 46.9], |
40 |
| - [6.57268, 46.51333], |
41 |
| - ], |
42 |
| - WGS84.epsg |
43 |
| - ) |
44 |
| - expect(result).to.be.an('Array').lengthOf(4) |
45 |
| - result.forEach((coord) => { |
46 |
| - expect(LV95.isInBounds(...coord)).to.be.true |
47 |
| - }) |
48 |
| - }) |
49 |
| - }) |
50 |
| - |
51 |
| - describe('formatMeters()', () => { |
52 |
| - it('format meters', () => { |
53 |
| - expect(formatMeters(42)).to.equal('42 m') |
54 |
| - expect(formatMeters(4002)).to.equal('4 km') |
55 |
| - expect(formatMeters(4200)).to.equal('4.2 km') |
56 |
| - expect(formatMeters(4200000)).to.equal("4'200 km") |
57 |
| - }) |
58 |
| - it('format squared meters', () => { |
59 |
| - expect(formatMeters(42, { dim: 2 })).to.equal('42 m²') |
60 |
| - expect(formatMeters(4002, { dim: 2 })).to.equal("4'002 m²") |
61 |
| - expect(formatMeters(4200, { dim: 2 })).to.equal("4'200 m²") |
62 |
| - expect(formatMeters(4200000, { dim: 2 })).to.equal('4.2 km²') |
63 |
| - expect(formatMeters(4200000000, { dim: 2 })).to.equal("4'200 km²") |
64 |
| - }) |
65 |
| - }) |
66 |
| - |
67 |
| - describe('formatPointCoordinates()', () => { |
68 |
| - it('format coordinates', () => { |
69 |
| - expect(formatPointCoordinates([2533541.8057776038, 1151703.909974419])).to.eql( |
70 |
| - "2'533'542, 1'151'704" |
71 |
| - ) |
72 |
| - }) |
73 |
| - }) |
74 |
| - |
75 |
| - describe('formatTime()', () => { |
76 |
| - it('format time', () => { |
77 |
| - expect(formatTime(null)).to.equal('-') |
78 |
| - expect(formatTime(42)).to.equal('42min') |
79 |
| - expect(formatTime(1200)).to.equal('20h') |
80 |
| - expect(formatTime(1230)).to.equal('20h 30min') |
81 |
| - expect(formatTime(1202)).to.equal('20h 2min') |
82 |
| - }) |
83 |
| - }) |
84 |
| - |
85 | 8 | describe('wrapXCoordinates()', () => {
|
86 | 9 | it('Wrap in place', () => {
|
87 | 10 | const original = [
|
|
0 commit comments