Add tests for invalid shifts
This commit is contained in:
@@ -41,6 +41,26 @@ describe.only('sensiplan', () => {
|
|||||||
const status = detectTemperatureShift(noTempShift)
|
const status = detectTemperatureShift(noTempShift)
|
||||||
expect(status).to.eql({ detected: false })
|
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', () => {
|
describe('1st exception rule', () => {
|
||||||
@@ -61,6 +81,19 @@ describe.only('sensiplan', () => {
|
|||||||
const status = detectTemperatureShift(firstExceptionNoShift)
|
const status = detectTemperatureShift(firstExceptionNoShift)
|
||||||
expect(status).to.eql({ detected: false })
|
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 }
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
Reference in New Issue
Block a user