|
|
@@ -6,39 +6,53 @@ const {
|
|
|
parse,
|
|
|
serialize,
|
|
|
} = require('../../../../xml/register-party/query-registration');
|
|
|
-const { queryRegistration1Xml } = require('./xml-requests');
|
|
|
-const { queryRegistration1 } = require('./js-requests');
|
|
|
+const {
|
|
|
+ queryRegistrationMinXml,
|
|
|
+ queryRegistrationMaxXml,
|
|
|
+ queryRegistrationMissingRequiredXml,
|
|
|
+} = require('./xml-requests');
|
|
|
+const { queryRegistrationMin, queryRegistrationMax } = require('./js-requests');
|
|
|
|
|
|
describe('Query Registration', function() {
|
|
|
- describe('serialize', function() {
|
|
|
- let serializedRequest;
|
|
|
+ describe('parse', function() {
|
|
|
+ it('successfully parses min xml', async function() {
|
|
|
+ const parsedResponse = await parse(queryRegistrationMinXml);
|
|
|
+ expect(parsedResponse).to.eql(queryRegistrationMin);
|
|
|
+ });
|
|
|
|
|
|
- before(async () => {
|
|
|
- serializedRequest = await serialize(queryRegistration1);
|
|
|
+ it('successfully parses max xml', async function() {
|
|
|
+ const parsedResponse = await parse(queryRegistrationMaxXml);
|
|
|
+ expect(parsedResponse).to.eql(queryRegistrationMax);
|
|
|
});
|
|
|
|
|
|
- it('successfully parses valid message', function() {
|
|
|
- expect(serializedRequest).to.eql(
|
|
|
- '<oadr2b:oadrPayload xmlns:oadr2b="http://openadr.org/oadr-2.0b/2012/07"><oadr2b:oadrSignedObject><oadr2b:oadrQueryRegistration xmlns:ei="http://docs.oasis-open.org/ns/energyinterop/201110" ei:schemaVersion="2.0b"><pyld:requestID xmlns:pyld="http://docs.oasis-open.org/ns/energyinterop/201110/payloads">12345</pyld:requestID></oadr2b:oadrQueryRegistration></oadr2b:oadrSignedObject></oadr2b:oadrPayload>',
|
|
|
- );
|
|
|
+ it('successfully parses serialized value', async function() {
|
|
|
+ const serialized = serialize(queryRegistrationMax);
|
|
|
+ const parsedResponse = await parse(serialized);
|
|
|
+ expect(parsedResponse).to.eql(queryRegistrationMax);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('throws Error on missing required field', async function() {
|
|
|
+ let lastError;
|
|
|
+ try {
|
|
|
+ await parse(queryRegistrationMissingRequiredXml);
|
|
|
+ } catch (e) {
|
|
|
+ lastError = e;
|
|
|
+ }
|
|
|
+ expect(lastError).to.be.an('error');
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- describe('parse', function() {
|
|
|
- let parsedRequest;
|
|
|
+ describe('serialize', function() {
|
|
|
+ let serializedResponse;
|
|
|
|
|
|
before(async () => {
|
|
|
- parsedRequest = await parse(queryRegistration1Xml);
|
|
|
- });
|
|
|
-
|
|
|
- it('successfully parses valid message', function() {
|
|
|
- expect(parsedRequest.requestId).to.eql('4323');
|
|
|
+ serializedResponse = await serialize(queryRegistrationMaxXml);
|
|
|
});
|
|
|
|
|
|
- it('successfully parses serialized value', async function() {
|
|
|
- const serialized = serialize(queryRegistration1);
|
|
|
- const parsedResponse = await parse(serialized);
|
|
|
- expect(parsedResponse).to.eql(queryRegistration1);
|
|
|
+ it('successfully serializes valid message', function() {
|
|
|
+ expect(serializedResponse).to.eql(
|
|
|
+ '<oadr2b:oadrPayload xmlns:oadr2b="http://openadr.org/oadr-2.0b/2012/07"><oadr2b:oadrSignedObject><oadr2b:oadrQueryRegistration xmlns:ei="http://docs.oasis-open.org/ns/energyinterop/201110" ei:schemaVersion="2.0b"><pyld:requestID xmlns:pyld="http://docs.oasis-open.org/ns/energyinterop/201110/payloads"></pyld:requestID></oadr2b:oadrQueryRegistration></oadr2b:oadrSignedObject></oadr2b:oadrPayload>',
|
|
|
+ );
|
|
|
});
|
|
|
});
|
|
|
});
|