canceled-party-registration.spec.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. 'use strict';
  2. const { expect } = require('chai');
  3. const { parse, serialize } = require('../../../../xml/register-party/canceled-party-registration');
  4. const { canceledPartyRegistration1Xml } = require('./xml-responses');
  5. const { canceledPartyRegistration1 } = require('./js-responses');
  6. describe('Canceled Party Registration', function() {
  7. describe('serialize', function() {
  8. let serializedResponse;
  9. before(async () => {
  10. serializedResponse = await serialize(canceledPartyRegistration1);
  11. });
  12. it ('successfully serializes valid message', function() {
  13. expect(serializedResponse).to.eql('<oadr2b:oadrPayload xmlns:oadr2b="http://openadr.org/oadr-2.0b/2012/07"><oadr2b:oadrSignedObject><oadr2b:oadrCanceledPartyRegistration 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">334455</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></oadr2b:oadrCanceledPartyRegistration></oadr2b:oadrSignedObject></oadr2b:oadrPayload>');
  14. });
  15. });
  16. describe('parse', function() {
  17. let parsedResponse;
  18. before(async () => {
  19. parsedResponse = await parse(canceledPartyRegistration1Xml);
  20. });
  21. it ('successfully parses valid message', function() {
  22. expect(parsedResponse.responseCode).to.eql('200');
  23. expect(parsedResponse.responseDescription).to.eql('OK');
  24. expect(parsedResponse.responseRequestId).to.eql('4323');
  25. expect(parsedResponse.venId).to.eql('3f59d85fbdf3997dbeb1');
  26. expect(parsedResponse.registrationId).to.eql('3bd3c02dc6965c8b9240');
  27. });
  28. it ('successfully parses serialized value', async function() {
  29. const serialized = serialize(canceledPartyRegistration1);
  30. const parsedResponse = await parse(serialized);
  31. expect(parsedResponse).to.eql(canceledPartyRegistration1);
  32. });
  33. });
  34. });