Change function signature and remove fixtures
This commit is contained in:
+4
-5
@@ -1,7 +1,6 @@
|
|||||||
function getTemperatureStatus(targetDateString, previousDaysInCycle) {
|
function detectTemperatureShift(temperaturesOfCycle) {
|
||||||
const tempValues = previousDaysInCycle
|
// sensiplan rounds temps to the nearest 0.05
|
||||||
.filter(day => day.temperature)
|
const tempValues = temperaturesOfCycle.map(val => rounded(val, 0.05))
|
||||||
.map(day => !day.temperature.exclude && rounded(day.temperature.value, 0.05))
|
|
||||||
|
|
||||||
let detectingPotentialHighLevel = false
|
let detectingPotentialHighLevel = false
|
||||||
|
|
||||||
@@ -49,5 +48,5 @@ function rounded(val, step) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
getTemperatureStatus
|
detectTemperatureShift
|
||||||
}
|
}
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
[{
|
|
||||||
"date": "2018-06-04",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.7,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-05",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.57,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-06",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.47,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-07",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.49,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-09",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.57,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-10",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.62,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-11",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.55,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-12",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.8,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-13",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.86,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-14",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.77,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-15",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.57,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
-67
@@ -1,67 +0,0 @@
|
|||||||
[{
|
|
||||||
"date": "2018-06-04",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.7,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-05",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.57,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-06",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.47,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-07",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.49,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-09",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.57,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-10",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.62,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-11",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.55,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-12",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.8,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-13",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.86,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-14",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.77,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-15",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.63,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
Vendored
-31
@@ -1,31 +0,0 @@
|
|||||||
[{
|
|
||||||
"date": "2018-06-04",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.7,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-05",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.57,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-06",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.47,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-07",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.49,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-09",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.57,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
-61
@@ -1,61 +0,0 @@
|
|||||||
[{
|
|
||||||
"date": "2018-06-04",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.7,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-05",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.57,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-06",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.47,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-07",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.49,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-09",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.57,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-10",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.62,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-11",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.55,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-12",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.8,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-13",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.86,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-14",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.77,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
-61
@@ -1,61 +0,0 @@
|
|||||||
[{
|
|
||||||
"date": "2018-06-04",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.7,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-05",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.57,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-06",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.47,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-07",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.49,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-09",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.57,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-10",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.62,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-11",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.55,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-12",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.8,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-13",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.86,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
"date": "2018-06-14",
|
|
||||||
"temperature": {
|
|
||||||
"value": 36.8,
|
|
||||||
"exclude": null
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
+11
-11
@@ -1,10 +1,5 @@
|
|||||||
import chai from 'chai'
|
import chai from 'chai'
|
||||||
import { getTemperatureStatus } from '../lib/sensiplan'
|
import { detectTemperatureShift } from '../lib/sensiplan'
|
||||||
import tempShift from './fixtures/regular-rule-shift.json'
|
|
||||||
import noTempShift from './fixtures/regular-rule-no-shift.json'
|
|
||||||
import lowerTempDays from './fixtures/lower-temps.json'
|
|
||||||
import firstException from './fixtures/first-exception-rule.json'
|
|
||||||
import firstExceptionNoShift from './fixtures/first-exception-rule-no-shift.json'
|
|
||||||
|
|
||||||
const expect = chai.expect
|
const expect = chai.expect
|
||||||
|
|
||||||
@@ -12,7 +7,8 @@ describe.only('sensiplan', () => {
|
|||||||
describe('getTemperatureStatus', () => {
|
describe('getTemperatureStatus', () => {
|
||||||
describe('regular rule', () => {
|
describe('regular rule', () => {
|
||||||
it('reports lower temperature status before shift', function () {
|
it('reports lower temperature status before shift', function () {
|
||||||
const status = getTemperatureStatus('2018-06-09', lowerTempDays)
|
const lowerTemps = [36.7, 36.57, 36.47, 36.49, 36.57]
|
||||||
|
const status = detectTemperatureShift(lowerTemps)
|
||||||
expect(status).to.eql({
|
expect(status).to.eql({
|
||||||
low: [36.7, 36.55, 36.45, 36.5, 36.55],
|
low: [36.7, 36.55, 36.45, 36.5, 36.55],
|
||||||
ltl: 36.7,
|
ltl: 36.7,
|
||||||
@@ -22,7 +18,8 @@ describe.only('sensiplan', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('detects temperature shift correctly', function () {
|
it('detects temperature shift correctly', function () {
|
||||||
const status = getTemperatureStatus('2018-06-14', tempShift)
|
const tempShift = [36.7, 36.57, 36.47, 36.49, 36.57, 36.62, 36.55, 36.8, 36.86, 36.8]
|
||||||
|
const status = detectTemperatureShift(tempShift)
|
||||||
expect(status).to.eql({
|
expect(status).to.eql({
|
||||||
low: [36.7, 36.55, 36.45, 36.5, 36.55, 36.6, 36.55],
|
low: [36.7, 36.55, 36.45, 36.5, 36.55, 36.6, 36.55],
|
||||||
ltl: 36.6,
|
ltl: 36.6,
|
||||||
@@ -32,7 +29,8 @@ describe.only('sensiplan', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('detects missing temperature shift correctly', function () {
|
it('detects missing temperature shift correctly', function () {
|
||||||
const status = getTemperatureStatus('2018-06-14', noTempShift)
|
const noTempShift = [36.7, 36.57, 36.47, 36.49, 36.57, 36.62, 36.55, 36.8, 36.86, 36.77]
|
||||||
|
const status = detectTemperatureShift(noTempShift)
|
||||||
expect(status).to.eql({
|
expect(status).to.eql({
|
||||||
low: [36.7, 36.55, 36.45, 36.5, 36.55, 36.6, 36.55],
|
low: [36.7, 36.55, 36.45, 36.5, 36.55, 36.6, 36.55],
|
||||||
ltl: 36.6,
|
ltl: 36.6,
|
||||||
@@ -44,7 +42,8 @@ describe.only('sensiplan', () => {
|
|||||||
|
|
||||||
describe('1st exception rule', () => {
|
describe('1st exception rule', () => {
|
||||||
it('detects temperature shift', function () {
|
it('detects temperature shift', function () {
|
||||||
const status = getTemperatureStatus('2018-06-14', firstException)
|
const firstException = [36.7, 36.57, 36.47, 36.49, 36.57, 36.62, 36.55, 36.8, 36.86, 36.77, 36.63]
|
||||||
|
const status = detectTemperatureShift(firstException)
|
||||||
expect(status).to.eql({
|
expect(status).to.eql({
|
||||||
low: [36.7, 36.55, 36.45, 36.5, 36.55, 36.6, 36.55],
|
low: [36.7, 36.55, 36.45, 36.5, 36.55, 36.6, 36.55],
|
||||||
ltl: 36.6,
|
ltl: 36.6,
|
||||||
@@ -54,7 +53,8 @@ describe.only('sensiplan', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('detects missing temperature shift correctly', function () {
|
it('detects missing temperature shift correctly', function () {
|
||||||
const status = getTemperatureStatus('2018-06-14', firstExceptionNoShift)
|
const firstExceptionNoShift = [36.7, 36.57, 36.47, 36.49, 36.57, 36.62, 36.55, 36.8, 36.86, 36.77, 36.57]
|
||||||
|
const status = detectTemperatureShift(firstExceptionNoShift)
|
||||||
expect(status).to.eql({
|
expect(status).to.eql({
|
||||||
low: [36.7, 36.55, 36.45, 36.5, 36.55, 36.6, 36.55],
|
low: [36.7, 36.55, 36.45, 36.5, 36.55, 36.6, 36.55],
|
||||||
ltl: 36.6,
|
ltl: 36.6,
|
||||||
|
|||||||
Reference in New Issue
Block a user