diff --git a/src/server/test/web/readingsBarGroupQuantity.js b/src/server/test/web/readingsBarGroupQuantity.js index 4cc4f45e7..514a854db 100644 --- a/src/server/test/web/readingsBarGroupQuantity.js +++ b/src/server/test/web/readingsBarGroupQuantity.js @@ -27,7 +27,6 @@ mocha.describe('readings API', () => { mocha.describe('readings test, test if data returned by API is as expected', () => { mocha.describe('for bar charts', () => { mocha.describe('for quantity groups', () => { - mocha.it('BG1: 1 day bars for 15 + 20 minute reading intervals and quantity units with +-inf start/end time & kWh as kWh', async () =>{ //loads data into database await prepareTest(unitDatakWh, conversionDatakWh, meterDatakWhGroups, groupDatakWh) @@ -112,7 +111,7 @@ mocha.describe('readings API', () => { graphicUnitId: unitId }); // Check that the API reading is equal to what it is expected to equal expectReadingToEqualExpected(res, expected, GROUP_ID); - }); + }); mocha.it('BG6: 76 day bars (no values) for 15 + 20 minute reading intervals and quantity units with +-inf start/end time & kWh as kWh', async () =>{ //load data into database @@ -201,8 +200,68 @@ mocha.describe('readings API', () => { expectReadingToEqualExpected(res, expected, GROUP_ID); }); - // Add BG11 here - + mocha.it('BG11: 1 day bars for 15 + 20 minute reading intervals and quantity units with +-inf start/end time & kWh as BTU reverse conversion', async () => { + //load data into database + const unitData = unitDatakWh.concat([ + { + // u3 + name: 'MJ', + identifier: 'megaJoules', + unitRepresent: Unit.unitRepresentType.QUANTITY, + secInRate: 3600, + typeOfUnit: Unit.unitType.UNIT, + suffix: '', + displayable: Unit.displayableType.ALL, + preferredDisplay: false, + note: 'MJ' + }, + { + // 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' + } + ]); + const conversionData = conversionDatakWh.concat([ + { + // c6 + sourceName: 'MJ', + destinationName: 'kWh', + bidirectional: true, + slope: 1 / 3.6, + intercept: 0, + note: 'MJ → kWh' + }, + { + // c3 + sourceName: 'MJ', + destinationName: 'BTU', + bidirectional: true, + slope: 947.8, + intercept: 0, + note: 'MJ → BTU' + } + ]); + await prepareTest(unitData, conversionData, meterDatakWhGroups, groupDatakWh); + //get unit ID since the DB could use any value. + const unitId = await getUnitId('BTU'); + //Load the expected response data from the corresponding csv file + const expected = await parseExpectedCsv('src/server/test/web/readingsData/expected_bar_group_ri_15-20_mu_kWh_gu_BTU_st_-inf_et_inf_bd_1.csv'); + // Create a request to the API for unbounded reading times and save the response + const res = await chai.request(app).get(`/api/unitReadings/bar/groups/${GROUP_ID}`) + .query({ + timeInterval: ETERNITY.toString(), + barWidthDays: '1', + graphicUnitId: unitId }); + // Check that the API reading is equal to what it is expected to equal + expectReadingToEqualExpected(res, expected, GROUP_ID); + }); mocha.it('BG12: 1 day bars for 15 + 20 minute reading intervals and quantity units with +-inf start/end time & kWh as kg of CO2', async () =>{ const unitData = unitDatakWh.concat([ { @@ -275,4 +334,3 @@ mocha.describe('readings API', () => { }); }); }); -