| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- 'use strict';
- const { expect } = require('chai');
- const {
- parse,
- serialize,
- } = require('../../../../xml/register-party/created-party-registration');
- const {
- createdPartyRegistrationMinXml,
- createdPartyRegistrationMaxXml,
- createdPartyRegistrationMissingRequiredXml,
- } = require('./xml-responses');
- const {
- createdPartyRegistrationMin,
- createdPartyRegistrationMax,
- } = require('./js-responses');
- describe('Created Party Registration', function() {
- describe('parse', function() {
- it('successfully parses min xml', async function() {
- const parsedResponse = await parse(createdPartyRegistrationMinXml);
- expect(parsedResponse).to.eql(createdPartyRegistrationMin);
- });
- it('successfully parses max xml', async function() {
- const parsedResponse = await parse(createdPartyRegistrationMaxXml);
- expect(parsedResponse).to.eql(createdPartyRegistrationMax);
- });
- it('successfully parses serialized value', async function() {
- const serialized = serialize(createdPartyRegistrationMax);
- const parsedResponse = await parse(serialized);
- expect(parsedResponse).to.eql(createdPartyRegistrationMax);
- });
- it('throws Error on missing required field', async function() {
- let lastError;
- try {
- await parse(createdPartyRegistrationMissingRequiredXml);
- } catch (e) {
- lastError = e;
- }
- expect(lastError).to.be.an('error');
- });
- });
- describe('serialize', function() {
- it('successfully serializes valid object', async function() {
- const serializedResponse = await serialize(createdPartyRegistrationMax);
- expect(serializedResponse).to.eql(
- '<oadr2b:oadrPayload xmlns:oadr2b="http://openadr.org/oadr-2.0b/2012/07"><oadr2b:oadrSignedObject><oadr2b:oadrCreatedPartyRegistration xmlns:ei="http://docs.oasis-open.org/ns/energyinterop/201110" ei:schemaVersion="2.0b"><ei:eiResponse xmlns:ei="http://docs.oasis-open.org/ns/energyinterop/201110"><ei:responseCode>200</ei:responseCode><ei:responseDescription>OK</ei:responseDescription><pyld:requestID xmlns:pyld="http://docs.oasis-open.org/ns/energyinterop/201110/payloads">4323</pyld:requestID></ei:eiResponse><ei:registrationID xmlns:ei="http://docs.oasis-open.org/ns/energyinterop/201110">3bd3c02dc6965c8b9240</ei:registrationID><ei:venID xmlns:ei="http://docs.oasis-open.org/ns/energyinterop/201110">3f59d85fbdf3997dbeb1</ei:venID><ei:vtnID xmlns:ei="http://docs.oasis-open.org/ns/energyinterop/201110">VTN_ID1</ei:vtnID><oadr2b:oadrProfiles><oadr2b:oadrProfile><oadr2b:oadrProfileName>2.0b</oadr2b:oadrProfileName><oadr2b:oadrTransports><oadr2b:oadrTransport><oadr2b:oadrTransportName>simpleHttp</oadr2b:oadrTransportName></oadr2b:oadrTransport></oadr2b:oadrTransports></oadr2b:oadrProfile></oadr2b:oadrProfiles><oadr2b:oadrRequestedOadrPollFreq><cal:duration xmlns:cal="urn:ietf:params:xml:ns:icalendar-2.0">PT10S</cal:duration></oadr2b:oadrRequestedOadrPollFreq></oadr2b:oadrCreatedPartyRegistration></oadr2b:oadrSignedObject></oadr2b:oadrPayload>',
- );
- });
- });
- });
|