96 lines
3.1 KiB
JavaScript
96 lines
3.1 KiB
JavaScript
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')
|
|
})
|
|
|
|
it('finds first color for 3 kW', () => {
|
|
let localFeature = Object.create(featureWithOutput)
|
|
localFeature.properties.tags['socket:type2:output'] = "3 kW"
|
|
let outputFound = utils.guessOutputPowerFromFeature(featureWithOutput)
|
|
expect(outputFound).toEqual(3)
|
|
let color = colorUtils.getColor(localFeature)
|
|
expect(color).toEqual(colorUtils.colors[0])
|
|
})
|
|
it('finds 2nd color for 20 kW', () => {
|
|
let localFeature = Object.create(featureWithOutput)
|
|
localFeature.properties.tags['socket:type2:output'] = "20 kW"
|
|
let outputFound = utils.guessOutputPowerFromFeature(featureWithOutput)
|
|
expect(outputFound).toEqual(20)
|
|
let color = colorUtils.getColor(localFeature)
|
|
expect(color).toEqual(colorUtils.colors[1])
|
|
})
|
|
it('finds 3nd color for 50 kW', () => {
|
|
let localFeature = Object.create(featureWithOutput)
|
|
localFeature.properties.tags['socket:type2:output'] = "50 kW"
|
|
let outputFound = utils.guessOutputPowerFromFeature(featureWithOutput)
|
|
expect(outputFound).toEqual(50)
|
|
let color = colorUtils.getColor(localFeature)
|
|
expect(color).toEqual(colorUtils.colors[2])
|
|
})
|
|
it('finds 3nd color for 100 kW', () => {
|
|
let localFeature = Object.create(featureWithOutput)
|
|
localFeature.properties.tags['socket:type2:output'] = "100 kW"
|
|
let outputFound = utils.guessOutputPowerFromFeature(featureWithOutput)
|
|
expect(outputFound).toEqual(100)
|
|
let color = colorUtils.getColor(localFeature)
|
|
expect(color).toEqual(colorUtils.colors[3])
|
|
})
|
|
it('finds 4nd color for 200 kW', () => {
|
|
let localFeature = Object.create(featureWithOutput)
|
|
localFeature.properties.tags['socket:type2:output'] = "200 kW"
|
|
let outputFound = utils.guessOutputPowerFromFeature(featureWithOutput)
|
|
expect(outputFound).toEqual(200)
|
|
let color = colorUtils.getColor(localFeature)
|
|
expect(color).toEqual(colorUtils.colors[4])
|
|
})
|
|
it('finds 5th color for 300 kW', () => {
|
|
let localFeature = Object.create(featureWithOutput)
|
|
localFeature.properties.tags['socket:type2:output'] = "300 kW"
|
|
let outputFound = utils.guessOutputPowerFromFeature(featureWithOutput)
|
|
expect(outputFound).toEqual(300)
|
|
let color = colorUtils.getColor(localFeature)
|
|
expect(color).toEqual(colorUtils.colors[5])
|
|
})
|
|
|
|
})
|
|
|
|
})
|