Add tests for invalid shifts

This commit is contained in:
Julia Friesel
2018-07-02 12:46:16 +02:00
parent 1eb3f4a14a
commit 8db92e96f3
+33
View File
@@ -41,6 +41,26 @@ describe.only('sensiplan', () => {
const status = detectTemperatureShift(noTempShift)
expect(status).to.eql({ detected: false })
})
it('detects shift after an earlier one was invalid', function () {
const temps = [36.4, 36.4, 36.4, 36.4, 36.4, 36.4, 36.6, 36.6, 36.4, 36.4, 36.7, 36.8, 36.9]
const status = detectTemperatureShift(temps)
expect(status).to.eql({
low: [36.4, 36.4, 36.6, 36.6, 36.4, 36.4],
ltl: 36.6,
high: [36.7, 36.8, 36.9],
detected: true,
rules: { regular: true }
})
})
it('detects 2 consecutive invalid shifts', function () {
const temps = [36.4, 36.4, 36.4, 36.4, 36.4, 36.4, 36.6, 36.6, 36.4, 36.4, 36.6, 36.6, 36.7]
const status = detectTemperatureShift(temps)
expect(status).to.eql({ detected: false })
})
})
describe('1st exception rule', () => {
@@ -61,6 +81,19 @@ describe.only('sensiplan', () => {
const status = detectTemperatureShift(firstExceptionNoShift)
expect(status).to.eql({ detected: false })
})
it('detects shift after an earlier one was invalid', function () {
const temps = [36.4, 36.4, 36.4, 36.4, 36.4, 36.4, 36.6, 36.6, 36.4, 36.4, 36.7, 36.7, 36.7, 36.7]
const status = detectTemperatureShift(temps)
expect(status).to.eql({
low: [36.4, 36.4, 36.6, 36.6, 36.4, 36.4],
ltl: 36.6,
high: [36.7, 36.7, 36.7, 36.7],
detected: true,
rules: { firstException: true }
})
})
})
})
})