testing colors

This commit is contained in:
Tykayn 2024-12-17 12:17:33 +01:00 committed by tykayn
parent be0ea5263c
commit bdd0aaaba2
3 changed files with 73 additions and 10 deletions

View file

@ -40,6 +40,56 @@ describe('testing on features', () => {
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 4nd 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])
})
})
})