Skip to content

Commit

Permalink
test: Migrate geo-utils test
Browse files Browse the repository at this point in the history
- remove old test & mockup files
  • Loading branch information
TheGreatRefrigerator committed Dec 7, 2022
1 parent ec56b4e commit 336c1ff
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 56 deletions.
47 changes: 47 additions & 0 deletions src/support/__tests__/geo-utils.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import GeoUtils from '../geo-utils'

const longLatCoordinates = [
[ 8.609088, 49.469343, 106 ],
[ 8.609031, 49.469324, 105 ],
[ 8.608745, 49.469206, 104.5 ],
[ 8.608382, 49.469103, 104.6 ],
[ 8.607994, 49.469053, 104.7 ]
]
const latLongCoordinates = [
[ 49.469343, 8.609088, 106 ],
[ 49.469324, 8.609031, 105 ],
[ 49.469206, 8.608745, 104.5 ],
[ 49.469103, 8.608382, 104.6 ],
[ 49.469053, 8.607994, 104.7 ]
]

describe('GeoUtils test', () => {
it('should switch coordinates in an matrix of coordinates', (done) => {
let result = GeoUtils.switchLatLonIndex(longLatCoordinates)
expect(JSON.stringify(result)).to.equal(JSON.stringify(latLongCoordinates))
done()
})

it('should build a latlng object', (done) => {
let result = GeoUtils.buildLatLong(49.46092806407386, 8.591051101684572)
expect(result.lng).to.equal(8.591051101684572)
expect(result.lat).to.equal(49.46092806407386)
done()
})

it('should normalize latlng object', (done) => {
let latlng = {lat:549.46092806407386, lng: 185.591051101684572}
GeoUtils.normalizeCoordinates(latlng)
expect(latlng.lng).to.equal(-174.40894889831543)
expect(latlng.lat).to.equal(-170.53907193592613)
done()
})

it('should not change already normalized latlng object ', (done) => {
let latlng = {lat:49.46092806407387, lng: 8.591051101684571}
GeoUtils.normalizeCoordinates(latlng)
expect(latlng.lng).to.equal(8.591051101684571)
expect(latlng.lat).to.equal(49.46092806407387)
done()
})
})
19 changes: 0 additions & 19 deletions tests/unit/mockups/geo-utils.js

This file was deleted.

37 changes: 0 additions & 37 deletions tests/unit/specs/geo-utils.spec.js

This file was deleted.

0 comments on commit 336c1ff

Please sign in to comment.