mirror of
https://forge.chapril.org/tykayn/libre-charge-map
synced 2025-06-20 01:34:43 +02:00
add test and split codebase
This commit is contained in:
parent
0614feaa03
commit
be0ea5263c
8 changed files with 6928 additions and 117 deletions
45
tests/main.test.js
Normal file
45
tests/main.test.js
Normal file
|
@ -0,0 +1,45 @@
|
|||
import utils from '../js/utils'
|
||||
import colorUtils from '../js/color-utils'
|
||||
|
||||
describe('testing on features', () => {
|
||||
const featureWithOutput = {
|
||||
properties: {
|
||||
tags: {
|
||||
'socket:type2:output': '30 kW'
|
||||
}
|
||||
}
|
||||
}
|
||||
const featureWithBadOutput = {
|
||||
properties: {
|
||||
tags: {
|
||||
'socket:type2:output': '50000'
|
||||
}
|
||||
}
|
||||
}
|
||||
const featureWithoutOutput = {
|
||||
properties: {
|
||||
tags: {
|
||||
'socket:type2': '2'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
describe('testing outputPower', () => {
|
||||
it('finds max outputpower when existing', () => {
|
||||
let outputFound = utils.guessOutputPowerFromFeature(featureWithOutput)
|
||||
expect(outputFound).toEqual(30)
|
||||
})
|
||||
})
|
||||
describe('testing corresponding color', () => {
|
||||
|
||||
it('finds undefined color', () => {
|
||||
let color = colorUtils.getColor(featureWithoutOutput)
|
||||
expect(color).toEqual('#c0b1b1')
|
||||
})
|
||||
it('finds bad color', () => {
|
||||
let color = colorUtils.getColor(featureWithBadOutput)
|
||||
expect(color).toEqual('#ff1414')
|
||||
})
|
||||
})
|
||||
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue