'use strict'; const { expect } = require('chai'); const { parse, serialize } = require('../../../../xml/report/update-report'); const { updateReportMinXml, updateReportTelemetryStatusXml, updateReportMaxXml, updateReportMissingRequiredXml, } = require('./xml-requests'); const { updateReportMin, updateReportMax, updateReportTelemetryStatus, } = require('./js-requests'); describe('Update Report', function() { describe('parse', function() { it('successfully parses min xml', async function() { const parsedResponse = await parse(updateReportMinXml); expect(parsedResponse).to.eql(updateReportMin); }); it('successfully parses max xml', async function() { const parsedResponse = await parse(updateReportMaxXml); expect(parsedResponse).to.eql(updateReportMax); }); it('successfully parses TelemetryStatus xml', async function() { const parsedResponse = await parse(updateReportTelemetryStatusXml); expect(parsedResponse).to.eql(updateReportTelemetryStatus); }); it('successfully parses serialized value', async function() { const serialized = serialize(updateReportMax); const parsedResponse = await parse(serialized); expect(parsedResponse).to.eql(updateReportMax); }); it('successfully parses serialized TelemetryStatus value', async function() { const serialized = serialize(updateReportTelemetryStatus); const parsedResponse = await parse(serialized); expect(parsedResponse).to.eql(updateReportTelemetryStatus); }); it('throws Error on missing required field', async function() { let lastError; try { await parse(updateReportMissingRequiredXml); } catch (e) { lastError = e; } expect(lastError).to.be.an('error'); }); }); describe('serialize', function() { it('successfully serializes valid object', async function() { const serializedResponse = await serialize(updateReportMax); expect(serializedResponse).to.eql( '87bbc1d44d903f31775887bbc1d44d903f317758TELEMETRY_USAGE2020-05-08T21:27:49.591-06:00TELEMETRY_USAGEPT1M2020-05-08T21:26:49.562-06:00PT30S2020-05-08T21:26:49.562-06:00161.97970171999845rep1Quality Good - Non SpecificPT30S2020-05-08T21:27:19.594-06:00165.46849970752885rep1Quality Good - Non SpecificPT30S2020-05-08T21:27:49.591-06:00162.30118577122087rep1Quality Good - Non Specific', ); }); }); });