Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions src/server/test/web/readingsCompareGroupQuantity.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,73 @@ mocha.describe('readings API', () => {

});

mocha.it('CG11: 1 day shift end 2022-10-31 17:00:00 for 15 minute reading intervals and quantity units & kWh as BTU reverse conversion', async () => {

// Define unit u3 for MJ (megajoules)
const u3 = {
name: 'MJ',
identifier: 'megaJoules',
unitRepresent: Unit.unitRepresentType.QUANTITY,
secInRate: 3600,
typeOfUnit: Unit.unitType.UNIT,
suffix: '',
displayable: Unit.displayableType.ALL,
preferredDisplay: false,
note: 'MJ'
}
// Define unit u16 for BTU
const u16 = {
name: 'BTU',
identifier: '',
unitRepresent: Unit.unitRepresentType.QUANTITY,
secInRate: 3600,
typeOfUnit: Unit.unitType.UNIT,
suffix: '',
displayable: Unit.displayableType.ALL,
preferredDisplay: true,
note: 'OED created standard unit'
}
// Define conversion c6 for MJ to kWh (reverse of c2)
const c6 = {
sourceName: 'MJ',
destinationName: 'kWh',
bidirectional: true,
slope: 1 / 3.6,
intercept: 0,
note: 'MJ → kWh'
}
// Define conversion c3 for MJ to BTU
const c3 = {
sourceName: 'MJ',
destinationName: 'BTU',
bidirectional: true,
slope: 947.8,
intercept: 0,
note: 'MJ → BTU'
}
await prepareTest(
// adds u3 and u16 to u1, u2
unitDatakWh.concat([u3, u16]),
// adds c6 and c3 to c1 (c6 is reverse MJ→kWh instead of c2 kWh→MJ)
conversionDatakWh.concat([c6, c3]),
meterDatakWhGroups,
groupDatakWh
);
// Get the unit ID since the DB could use any value.
const unitId = await getUnitId('BTU');
const expected = [19334049.5356478, 20037163.9086933];

// for comparison, need the unitID, currentStart, currentEnd, shift
const res = await chai.request(app).get(`/api/compareReadings/groups/${GROUP_ID}`)
.query({
curr_start: '2022-10-31 00:00:00',
curr_end: '2022-10-31 17:00:00',
shift: 'P1D',
graphicUnitId: unitId
});
expectCompareToEqualExpected(res, expected, GROUP_ID);
});

// Add CG12 here

// Add CG13 here
Expand Down