@adobe/acc-js-sdk 1.1.8 → 1.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -5
- package/README.md +211 -1
- package/package-lock.json +843 -5820
- package/package.json +1 -1
- package/samples/005 - basics - persist.js +160 -0
- package/src/application.js +11 -0
- package/src/client.js +68 -25
- package/src/methodCache.js +24 -13
- package/src/soap.js +13 -1
- package/src/xtkCaster.js +61 -3
- package/test/application.test.js +38 -0
- package/test/caches.test.js +1 -1
- package/test/client.test.js +118 -3
- package/test/mock.js +41 -4
- package/test/xtkCaster.test.js +62 -0
- package/test/xtkPersist.test.js +97 -0
- package/test/xtkProxy.test.js +81 -0
package/test/client.test.js
CHANGED
|
@@ -727,9 +727,9 @@ describe('ACC Client', function () {
|
|
|
727
727
|
const element = { "@type": "element", "@xtkschema": "nms:recipient" }; // @xtkschema needed to determine root name
|
|
728
728
|
const document = { "@type": "document", "@xtkschema": "nms:recipient" };
|
|
729
729
|
|
|
730
|
-
const result = await client.NLWS.xtkAll.allTypes("Hello World", true, 1, 1000, 100000, "100000", "2020-12-31T12:34:56.789Z", "2020-12-31", element, document);
|
|
730
|
+
const result = await client.NLWS.xtkAll.allTypes("Hello World", true, 1, 1000, 100000, "100000", "2020-12-31T12:34:56.789Z", "2020-12-31", element, document, "xtk:operator|abc");
|
|
731
731
|
// Note: should match responses in GET_XTK_ALL_TYPES_RESPONSE
|
|
732
|
-
expect(result.length).toBe(
|
|
732
|
+
expect(result.length).toBe(11);
|
|
733
733
|
expect(result[0]).toBe("Hello World");
|
|
734
734
|
expect(result[1]).toBe(true);
|
|
735
735
|
expect(result[2]).toBe(1);
|
|
@@ -742,6 +742,7 @@ describe('ACC Client', function () {
|
|
|
742
742
|
expect(result[8]["@result"]).toBe("true");
|
|
743
743
|
expect(result[9]["@type"]).toBe("document");
|
|
744
744
|
expect(result[9]["@result"]).toBe("true");
|
|
745
|
+
expect(result[10]).toBe("xtk:operator|123");
|
|
745
746
|
|
|
746
747
|
client._transport.mockReturnValueOnce(Mock.LOGOFF_RESPONSE);
|
|
747
748
|
await client.NLWS.xtkSession.logoff();
|
|
@@ -3351,5 +3352,119 @@ describe('ACC Client', function () {
|
|
|
3351
3352
|
})
|
|
3352
3353
|
|
|
3353
3354
|
})
|
|
3354
|
-
})
|
|
3355
|
+
});
|
|
3356
|
+
|
|
3357
|
+
describe("Setting the xtkschema attribute", () => {
|
|
3358
|
+
it("Should support setting explicitely setting the xtkschema", async() => {
|
|
3359
|
+
const client = await Mock.makeClient();
|
|
3360
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
3361
|
+
await client.NLWS.xtkSession.logon();
|
|
3362
|
+
|
|
3363
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_SESSION_SCHEMA_RESPONSE);
|
|
3364
|
+
client._transport.mockReturnValueOnce(Mock.FILE_RES_WRITE_RESPONSE);
|
|
3365
|
+
await client.NLWS.xtkSession.write({ xtkschema: "nms:test" });
|
|
3366
|
+
expect(client._transport).toHaveBeenCalledTimes(3);
|
|
3367
|
+
expect(client._transport.mock.calls[2][0].data).toMatch("xtkschema=\"nms:test\"");
|
|
3368
|
+
});
|
|
3369
|
+
|
|
3370
|
+
it("Should default to soap parameter name", async() => {
|
|
3371
|
+
const client = await Mock.makeClient();
|
|
3372
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
3373
|
+
await client.NLWS.xtkSession.logon();
|
|
3374
|
+
|
|
3375
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_SESSION_SCHEMA_RESPONSE);
|
|
3376
|
+
client._transport.mockReturnValueOnce(Mock.FILE_RES_WRITE_RESPONSE);
|
|
3377
|
+
await client.NLWS.xtkSession.write({ });
|
|
3378
|
+
expect(client._transport).toHaveBeenCalledTimes(3);
|
|
3379
|
+
expect(client._transport.mock.calls[2][0].data).toMatch("<doc xsi:type="); // parameter of xtk:session#Write is named "doc" in the schema
|
|
3380
|
+
});
|
|
3381
|
+
|
|
3382
|
+
it("Should have a hardcoded value for nms:rtEvent#PushEvent", async() => {
|
|
3383
|
+
const client = await Mock.makeClient();
|
|
3384
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
3385
|
+
await client.NLWS.xtkSession.logon();
|
|
3386
|
+
|
|
3387
|
+
client._transport.mockReturnValueOnce(Mock.GET_NMS_RTEVENT_SCHEMA_RESPONSE);
|
|
3388
|
+
client._transport.mockReturnValueOnce(Promise.resolve(`<?xml version='1.0'?>
|
|
3389
|
+
<SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:ns='urn:nms:rtEvent' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
|
|
3390
|
+
<SOAP-ENV:Body>
|
|
3391
|
+
<PushEventResponse xmlns='urn:nms:rtEvent' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
|
|
3392
|
+
<plId xsi:type='xsd:long'>72057594039155998</plId>
|
|
3393
|
+
</PushEventResponse>
|
|
3394
|
+
</SOAP-ENV:Body>
|
|
3395
|
+
</SOAP-ENV:Envelope>`));
|
|
3396
|
+
await client.NLWS.nmsRtEvent.pushEvent({ });
|
|
3397
|
+
expect(client._transport).toHaveBeenCalledTimes(3);
|
|
3398
|
+
expect(client._transport.mock.calls[2][0].data).toMatch("<rtEvent/>"); // document name for nms:rtEvent#PushEvent is named "rtEvent"
|
|
3399
|
+
});
|
|
3400
|
+
|
|
3401
|
+
it("Should be set automatically for non-static methods when object is a proxy", async () => {
|
|
3402
|
+
const client = await Mock.makeClient();
|
|
3403
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
3404
|
+
await client.NLWS.xtkSession.logon();
|
|
3405
|
+
|
|
3406
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_QUERY_SCHEMA_RESPONSE);
|
|
3407
|
+
client._transport.mockReturnValueOnce(Mock.GET_QUERY_EXECUTE_RESPONSE);
|
|
3408
|
+
var query = client.NLWS.xtkQueryDef.create({ schema: "nms:extAccount" });
|
|
3409
|
+
await query.executeQuery();
|
|
3410
|
+
|
|
3411
|
+
expect(client._transport).toHaveBeenCalledTimes(3);
|
|
3412
|
+
expect(client._transport.mock.calls[2][0].data).toMatch("xtkschema=\"xtk:queryDef\"");
|
|
3413
|
+
});
|
|
3414
|
+
|
|
3415
|
+
it("Should be set automatically for non-static methods when object is a JSON object", async () => {
|
|
3416
|
+
const client = await Mock.makeClient();
|
|
3417
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
3418
|
+
await client.NLWS.xtkSession.logon();
|
|
3419
|
+
|
|
3420
|
+
client._transport.mockReturnValueOnce(Mock.GET_NMS_DELIVERY_SCHEMA_RESPONSE);
|
|
3421
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_SESSION_SCHEMA_RESPONSE);
|
|
3422
|
+
client._transport.mockReturnValueOnce(Mock.GET_DELIVERY_NEW_INSTANCE_RESPONSE);
|
|
3423
|
+
await client._callMethod("NewInstance", {
|
|
3424
|
+
schemaId: 'nms:delivery',
|
|
3425
|
+
object: { },
|
|
3426
|
+
}, []);
|
|
3427
|
+
expect(client._transport).toHaveBeenCalledTimes(4);
|
|
3428
|
+
expect(client._transport.mock.calls[3][0].data).toMatch("<delivery xtkschema=\"nms:delivery\"/>");
|
|
3429
|
+
});
|
|
3430
|
+
|
|
3431
|
+
it("Should be set automatically for non-static methods when object is a XML document", async () => {
|
|
3432
|
+
const client = await Mock.makeClient();
|
|
3433
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
3434
|
+
await client.NLWS.xtkSession.logon();
|
|
3435
|
+
|
|
3436
|
+
client._transport.mockReturnValueOnce(Mock.GET_NMS_DELIVERY_SCHEMA_RESPONSE);
|
|
3437
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_SESSION_SCHEMA_RESPONSE);
|
|
3438
|
+
client._transport.mockReturnValueOnce(Mock.GET_DELIVERY_NEW_INSTANCE_RESPONSE);
|
|
3439
|
+
const doc = DomUtil.parse("<delivery label=\"hello\"/>");
|
|
3440
|
+
expect(doc.nodeType).toBe(9);
|
|
3441
|
+
await client._callMethod("NewInstance", {
|
|
3442
|
+
schemaId: 'nms:delivery',
|
|
3443
|
+
representation: 'xml',
|
|
3444
|
+
object: doc,
|
|
3445
|
+
}, []);
|
|
3446
|
+
expect(client._transport).toHaveBeenCalledTimes(4);
|
|
3447
|
+
expect(client._transport.mock.calls[3][0].data).toMatch("<delivery label=\"hello\" xtkschema=\"nms:delivery\"/>");
|
|
3448
|
+
});
|
|
3449
|
+
|
|
3450
|
+
it("Should be set automatically for non-static methods when object is a XML element", async () => {
|
|
3451
|
+
const client = await Mock.makeClient();
|
|
3452
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
3453
|
+
await client.NLWS.xtkSession.logon();
|
|
3454
|
+
|
|
3455
|
+
client._transport.mockReturnValueOnce(Mock.GET_NMS_DELIVERY_SCHEMA_RESPONSE);
|
|
3456
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_SESSION_SCHEMA_RESPONSE);
|
|
3457
|
+
client._transport.mockReturnValueOnce(Mock.GET_DELIVERY_NEW_INSTANCE_RESPONSE);
|
|
3458
|
+
const doc = DomUtil.parse("<delivery label=\"hello\"/>");
|
|
3459
|
+
expect(doc.nodeType).toBe(9);
|
|
3460
|
+
await client._callMethod("NewInstance", {
|
|
3461
|
+
schemaId: 'nms:delivery',
|
|
3462
|
+
representation: 'xml',
|
|
3463
|
+
object: doc.documentElement,
|
|
3464
|
+
}, []);
|
|
3465
|
+
expect(client._transport).toHaveBeenCalledTimes(4);
|
|
3466
|
+
expect(client._transport.mock.calls[3][0].data).toMatch("<delivery label=\"hello\" xtkschema=\"nms:delivery\"/>");
|
|
3467
|
+
});
|
|
3468
|
+
});
|
|
3469
|
+
|
|
3355
3470
|
});
|
package/test/mock.js
CHANGED
|
@@ -184,6 +184,8 @@ const GET_XTK_SESSION_SCHEMA_RESPONSE = Promise.resolve(`<?xml version='1.0'?>
|
|
|
184
184
|
<pdomDoc xsi:type='ns:Element' SOAP-ENV:encodingStyle='http://xml.apache.org/xml-soap/literalxml'>
|
|
185
185
|
<schema namespace="xtk" name="session" implements="xtk:persist">
|
|
186
186
|
<interface name="persist">
|
|
187
|
+
<method name="NewInstance">
|
|
188
|
+
</method>
|
|
187
189
|
<method name="Write" static="true">
|
|
188
190
|
<parameters>
|
|
189
191
|
<param name="doc" type="DOMDocument"/>
|
|
@@ -301,6 +303,35 @@ const GET_XTK_QUERY_SCHEMA_RESPONSE = Promise.resolve(`<?xml version='1.0'?>
|
|
|
301
303
|
</SOAP-ENV:Body>
|
|
302
304
|
</SOAP-ENV:Envelope>`);
|
|
303
305
|
|
|
306
|
+
const GET_NMS_DELIVERY_SCHEMA_RESPONSE = Promise.resolve(`<?xml version='1.0'?>
|
|
307
|
+
<SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:ns='urn:wpp:default' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
|
|
308
|
+
<SOAP-ENV:Body>
|
|
309
|
+
<GetEntityIfMoreRecentResponse xmlns='urn:wpp:default' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
|
|
310
|
+
<pdomDoc xsi:type='ns:Element' SOAP-ENV:encodingStyle='http://xml.apache.org/xml-soap/literalxml'>
|
|
311
|
+
<schema name="delivery" namespace="nms" implements="xtk:persist">
|
|
312
|
+
<element name="delivery"></element>
|
|
313
|
+
<methods>
|
|
314
|
+
<method name="Test">
|
|
315
|
+
</method>
|
|
316
|
+
</methods>
|
|
317
|
+
</schema>
|
|
318
|
+
</pdomDoc>
|
|
319
|
+
</GetEntityIfMoreRecentResponse>
|
|
320
|
+
</SOAP-ENV:Body>
|
|
321
|
+
</SOAP-ENV:Envelope>`);
|
|
322
|
+
|
|
323
|
+
const GET_DELIVERY_TEST_RESPONSE = Promise.resolve(`<?xml version='1.0'?>
|
|
324
|
+
<SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:ns='urn:nms:delivery' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
|
|
325
|
+
<SOAP-ENV:Body>
|
|
326
|
+
<TestResponse xmlns='urn:nms:delivery' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
|
|
327
|
+
<entity xsi:type='ns:Element' SOAP-ENV:encodingStyle='http://xml.apache.org/xml-soap/literalxml'>
|
|
328
|
+
<delivery>
|
|
329
|
+
</delivery>
|
|
330
|
+
</entity>
|
|
331
|
+
</TestResponse>
|
|
332
|
+
</SOAP-ENV:Body>
|
|
333
|
+
</SOAP-ENV:Envelope>`);
|
|
334
|
+
|
|
304
335
|
const GET_MID_EXT_ACCOUNT_RESPONSE = (encryptedPassword) => {
|
|
305
336
|
return Promise.resolve(`<?xml version='1.0'?>
|
|
306
337
|
<SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:ns='urn:xtk:queryDef' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
|
|
@@ -414,6 +445,8 @@ const GET_XTK_ALL_SCHEMA_RESPONSE = Promise.resolve(`<?xml version='1.0'?>
|
|
|
414
445
|
<param inout="out" name="element" type="DOMElement"/>
|
|
415
446
|
<param inout="in" name="element" type="DOMDocument"/>
|
|
416
447
|
<param inout="out" name="element" type="DOMDocument"/>
|
|
448
|
+
<param inout="in" name="primarykey" type="primarykey"/>
|
|
449
|
+
<param inout="out" name="string" type="primarykey"/>
|
|
417
450
|
</parameters>
|
|
418
451
|
</method>
|
|
419
452
|
<method name="Unsupported" static="true">
|
|
@@ -447,6 +480,7 @@ const GET_XTK_ALL_TYPES_RESPONSE = Promise.resolve(`<?xml version='1.0'?>
|
|
|
447
480
|
<dummy xsi:type='xsd:date'>2020-12-31</dummy>
|
|
448
481
|
<dummy xsi:type='ns:Element'><root type='element' result='true'/></dummy>
|
|
449
482
|
<dummy xsi:type=''><root type='document' result='true'/></dummy>
|
|
483
|
+
<dummy xsi:type='xsd:primarykey'>xtk:operator|123</dummy>
|
|
450
484
|
</AllTypesResponse>
|
|
451
485
|
</SOAP-ENV:Body>
|
|
452
486
|
</SOAP-ENV:Envelope>`);
|
|
@@ -742,9 +776,6 @@ const GET_URL_RESPONSE = Promise.resolve(`<?xml version='1.0'?>
|
|
|
742
776
|
</SOAP-ENV:Body>
|
|
743
777
|
</SOAP-ENV:Envelope>`);
|
|
744
778
|
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
779
|
const GETMODIFIEDENTITIES_SCHEMA_RESPONSE = Promise.resolve(`<?xml version='1.0'?>
|
|
749
780
|
<SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:ns='urn:xtk:session' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
|
|
750
781
|
<SOAP-ENV:Body>
|
|
@@ -784,6 +815,9 @@ const GETMODIFIEDENTITIES_ERROR_RESPONSE = Promise.resolve(`<?xml version='1.0'?
|
|
|
784
815
|
</SOAP-ENV:Body>
|
|
785
816
|
</SOAP-ENV:Envelope>`);
|
|
786
817
|
|
|
818
|
+
|
|
819
|
+
const GET_DELIVERY_NEW_INSTANCE_RESPONSE = Promise.resolve(`<?xml version='1.0'?><SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:ns='urn:nms:delivery' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'><SOAP-ENV:Body><NewInstanceResponse xmlns='urn:nms:delivery' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'><entity xsi:type='ns:Element' SOAP-ENV:encodingStyle='http://xml.apache.org/xml-soap/literalxml'><delivery _operation="insert" analysisStep="0" budgetStatus="0" builtIn="false" contentStatus="0" created="2022-09-26 03:13:36.480Z" createdBy-id="6043" deleteStatus="0" deliveryMode="0" deliveryProvider-id="1855" extractionStatus="0" folder-id="1186" folderProcess-id="1206" id="9790" internalName="DM554" isModel="1" jobType="delivery" keepResult="false" label="Email" lastModified="2022-09-26 03:13:36.480Z" launchFCP="0" mapping-id="1775" maxPropositionCount="1" messageType="0" modifiedBy-id="6043" outOfProcess="false" priority="10" sandboxStatus="0" state="0" status="0" targetStatus="0" typology-id="1852" useTargetOffers="false" xtkschema="nms:delivery"><folder _cs="Delivery templates"/><folderProcess _cs="Deliveries"/><createdBy _cs="Gaurav Makkar (gmakkar@adobe.com)"/><modifiedBy _cs="Gaurav Makkar (gmakkar@adobe.com)"/><properties deliveryState="0" warning="false"/><deliveryProvider EMailFunction="0" NChar="0" _cs="Internal email delivery" account="" activationMode="2" active="1" activity="signal" awsKey="" awsRegion="" awsSecret="" azureTenant="" callbackServer="" clientId="" clientSecret="" created="2022-09-16 07:39:50.796Z" createdBy-id="0" dbName="" deliveryMode="1" deployed="0" encryptionType="0" fdaExtAccount-id="0" fileMethod="uploadFile" folder-id="1035" folderSetOfServices-id="0" httpRelayTarget="false" id="1855" imsOrgId="" imsRightsMask="" imsServer="" label="Internal email delivery" lastModified="2022-09-16 07:42:37.469Z" lastMultiUsed="" messageType="0" mirrorURL="" mobileConnector="127" modifiedBy-id="1062" multiMidMode="0" multiMidProvider="0" name="defaultEmailBulk" oAuth="0" onEveryRun="0" packageAutoExport="0" partner="1" password="" port="" productContext="" provider="Snowflake" redirectUrl="" server="" tenant="" timezone="_server_" timezoneName="Europe/Paris" type="3" unicodeData="0" useServerSideEncryption="0" userScope=""><analyticsConfig integrationName="defaultEmailBulk" persistence="7" purge="180" status="3"></analyticsConfig><webAnalyticsParams partner="1" persistence="7" purge="180"><integrationDetails integrationName="defaultEmailBulk" integrationValue="7281015239823888aa73636c74217b84"></integrationDetails></webAnalyticsParams><params allowTranslit="false" bindTimeout="60" dataInOptionalField="false" dataInTextField="false" defaultMoCharset="X-Gsm7Bit" defaultMtCharset="X-Gsm7Bit" deliverIdEncode="default" deliverIdEncode2="0" enableTLS="false" enquireLinkPeriod="30" errorExtractionRegex="\\b[eE][rR][rR]:([a-zA-Z0-9]{3})\\b" errorStatusRegex="^(?:EXPIRED|DELETED|UNDELIV|UNKNOWN|REJECT)" idExtractionRegex="\\b[iI][dD]:([a-fA-F0-9]{1,10})\\b" invalidIdAckLimit="0" maxBinds="1" maxWindow="10" messagePayload="false" messageTimeout="30" rateLimit="0" reconnectPeriod="10" sendFullPhoneNumber="false" skipTLSCertCheck="0" smscName="Generic" statusExtractionRegex="\\b[sS][tT][aA][tT]:([a-zA-Z0-9]{5,15})\\b" submitRespIdEncode="default" submitRespIdEncode2="0" successStatusRegex="^DELIV"><wapPush oAuth="0"/><mms oAuth="0"/><oauthParams thirdPartyApplication="true"/><facebookParams marketingURL="http://www.adobe.com" realtimeSubStatus="0"/><mscrm crmApiVersion="'auto'" crmDeploymentType="webapi" crmGrantType="0"/><salesforce apiVersion="'21.0'"/></params><ffda isFFDA="0" replicationWarehouse="" xxlSchemaSuffix=""/></deliveryProvider><forecast simuResponseType="0" weight="5" weightType="0"><weightFormula>$(deliveryWeight)</weightFormula></forecast><volume duration="1" rate="100"/><scheduling delayExtraction="0" validationMode="manual" webResPurged="false"><waves mode="0" splitDelay="86400" splitSize="20%"/><messagePreparation priority="0"/></scheduling><validation sandboxMode="0" sandboxModeEnforced="0" useBudgetValidation="true" useContentValidation="true" useExtractionValidation="true" useFCPValidation="true" useTargetValidation="true" validationMode="0"><target><validation delay="259200" type="0"/></target><content><validation delay="259200" type="0"/></content><budget><validation delay="259200" type="0"/></budget><extraction><validation delay="259200" type="0"/></extraction><forecast><validation delay="259200" type="0"/></forecast><starting><validation delay="259200" type="0"/></starting><edition><validation delay="259200" type="0"/></edition><external><validation delay="259200" type="0"/></external></validation><execution maxPersoTime="5" maxRetry="5" retryPeriod="3600"><controlGroup type="3"/></execution><typology _cs="Default typology"/><mapping _cs="Recipients (nms:recipient)" blackListAgency="@blackList" blackListEmail="Iif(@blackList!=0, 1, @blackListEmail)" blackListFax="Iif(@blackList!=0, 1,@blackListFax)" blackListPaper="Iif(@blackList!=0, 1,@blackListPostalMail)" blackListPhone="Iif(@blackList!=0, 1,@blackListPhone)" blackListSms="Iif(@blackList!=0, 1,@blackListMobile)" builtIn="1" countryCode="[location/@countryCode]" created="2022-09-16 07:39:50.496Z" createdBy-id="0" defaultOrigin-id="1861" email="Lower(@email)" facebook="" fax="@fax" folder-id="1171" format="@emailFormat" id="1775" isFfda="0" label="Recipients" lastModified="2022-09-16 07:39:52.859Z" modifiedBy-id="0" name="mapRecipient" paper="postalAddress" phone="@phone" recipientLink="" schema="nms:recipient" sms="@mobilePhone" targetSchema="nms:recipient" twitter=""><storage broadLogExclSchema="nms:excludeLogRcp" broadLogFilterKeys="" broadLogRcpKeys="" broadLogSchema="nms:broadLogRcp" broadLogTable="" exclusionType="2" trackingHasDeviceIP="0" trackingLogFilterKeys="" trackingLogRcpKeys="" trackingLogSchema="nms:trackingLogRcp" trackingLogTable=""></storage><social birthDate="@birthDate" email="@email" firstName="@firstName" gender="@gender" lastName="@lastName" locale="@language"/></mapping><scenario validityDuration="432000" webValidityDuration="5184000"/><fcpParameters addFormatInPrefix="true" fcpMailFormat="normal" fcpMode="specificTarget" ignoreBlacklist="true" ignoreDeduplicate="true" ignoreQuarantaine="false" keepDeliveryCode="false" labelPrefix="Proof" useSpecificOutputFile="false"/><mailParameters mirrorPagePolicy="default" needMirrorPage="0" useDefaultErrorAddress="true"><senderName><![CDATA[Automation Inc.]]></senderName><senderAddress><![CDATA[no-reply@Customer.rd.campaign.adobe.com]]></senderAddress><replyAddress><![CDATA[no-reply@Customer.rd.campaign.adobe.com]]></replyAddress><replyName><![CDATA[Automation Inc.]]></replyName></mailParameters><smsParameters mobileMsgType="0" smsAppType="2" smsMode="1" smsPriority="0"/><paperParameters addressPos="ownPage" colorSupport="bw" envelope="C6SW" priceCategory="letterPrio" rectoVerso="recto"/><targets addressField="__db__" allowUnchecked="true" blackListField="__db__" deduplicate="true" excludeOnMissingOffer="0" externalIdField="__db__" formatField="__db__" fromExternalSource="false" maxErrorCount="3" noRcpIdDedup="false" noReconciliation="false" qualityRequired="3" segmentCodeField="__db__" targetMode="0" useBlackList="true" useQuality="1" useQuarantine="1"><deliveryTarget nonEmpty="false"/><proofTarget nonEmpty="false"/><deliveryFile autoDelete="false" upload="true"/><proofFile autoDelete="false" upload="true"/><postalAddress addrDefinedField="__none__" addrErrorCountField="__none__" addrLastCheckField="__none__" addrQualityField="__none__" line1Field="__db__" line2Field="__db__" line3Field="__db__" line4Field="__db__" line5Field="__db__" line6Field="__db__" line7Field="__db__"/></targets><remoteContent remoteValidation="false"/><content IsImagePublished="false" embedImages="false" fcbContentType="0" formatSelection="preferences" htmlCompression="false" ignoreScripts="false" pdfCompression="true" pdfType="simple"><lineContentType><source>text</source></lineContentType><lineVersion><source>line</source></lineVersion><lineDeliveryType><source>pushMsg</source></lineDeliveryType><lineImageType><source>manual</source></lineImageType><lineMultiRegionLayoutType><source>1</source></lineMultiRegionLayoutType></content><output enableLinkDelivery="true" feedbackMode="none"><seedList insertMode="0"/><extraction><source batchSize="200" format="text" rejectsFromTextConnector="false" startPath="/" upload="true"><dataSourceConfig codepage="1252" colType="0" ignoreConfigCheck="false" textQualifier="none" timezone="_inherit_" useCR="false" useLF="false"/><dataSourceConfigDest codepage="1252" colType="0" ignoreConfigCheck="false" textQualifier="none" timezone="_inherit_" useCR="false" useLF="false"/></source><destination downloadDestFile="true" endRecord="0" progressLines="20" putUnmappedCols="true" splitOverOrigin="false" startPath="/" startRecord="0" transactionLines="200"><exportFormat allAsString="false" analyze="false" codepage="1252" delEscaping="duplicateDel" delimitor="delNone" format="text" lineEnd="0" saveTitle="true" separator="sepTab" timezone="_inherit_"><dataFormat decimalCount="-1" hideTime="false" orderDate="ymd" sepDate="/" sepDateTime=" " sepNumber="." sepThousand="false" sepTime=":" showMs="false" showSec="true" yearShort="false"/></exportFormat></destination></extraction></output><tracking enabled="true" openEnabled="true"><clickFormula><![CDATA[<%@ include option='NmsTracking_ClickFormula' %>]]></clickFormula><openFormula><![CDATA[<%@ include option='NmsTracking_OpenFormula' %>]]></openFormula></tracking><advancedParameters DBPreparationMode="0" codepage="65001" emailArchiving="false" emailBCCEmta="false" forceCodepage="false" outOfProcessMode="false" showSQL="false" useDBPreparation="false" useDataManagement="false" verifyMode="false"/><budgetParameters commitmentLevel="0" computationState="0"/></delivery></entity></NewInstanceResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>`);
|
|
820
|
+
|
|
787
821
|
// Public exports
|
|
788
822
|
exports.Mock = {
|
|
789
823
|
makeClient: makeClient,
|
|
@@ -804,6 +838,8 @@ exports.Mock = {
|
|
|
804
838
|
GET_OPTION_NOTFOUND_RESPONSE: GET_OPTION_NOTFOUND_RESPONSE,
|
|
805
839
|
GET_OPTION_MISSING_DATA_RESPONSE: GET_OPTION_MISSING_DATA_RESPONSE,
|
|
806
840
|
GET_XTK_QUERY_SCHEMA_RESPONSE: GET_XTK_QUERY_SCHEMA_RESPONSE,
|
|
841
|
+
GET_NMS_DELIVERY_SCHEMA_RESPONSE: GET_NMS_DELIVERY_SCHEMA_RESPONSE,
|
|
842
|
+
GET_DELIVERY_TEST_RESPONSE: GET_DELIVERY_TEST_RESPONSE,
|
|
807
843
|
GET_MID_EXT_ACCOUNT_RESPONSE: GET_MID_EXT_ACCOUNT_RESPONSE,
|
|
808
844
|
GET_BAD_EXT_ACCOUNT_RESPONSE: GET_BAD_EXT_ACCOUNT_RESPONSE,
|
|
809
845
|
GET_SECRET_KEY_OPTION_RESPONSE: GET_SECRET_KEY_OPTION_RESPONSE,
|
|
@@ -835,5 +871,6 @@ exports.Mock = {
|
|
|
835
871
|
INCREASE_VALUE_RESPONSE: INCREASE_VALUE_RESPONSE,
|
|
836
872
|
FILE_RES_WRITE_RESPONSE: FILE_RES_WRITE_RESPONSE,
|
|
837
873
|
PUBLISH_IF_NEEDED_RESPONSE: PUBLISH_IF_NEEDED_RESPONSE,
|
|
838
|
-
GET_URL_RESPONSE: GET_URL_RESPONSE
|
|
874
|
+
GET_URL_RESPONSE: GET_URL_RESPONSE,
|
|
875
|
+
GET_DELIVERY_NEW_INSTANCE_RESPONSE: GET_DELIVERY_NEW_INSTANCE_RESPONSE
|
|
839
876
|
}
|
package/test/xtkCaster.test.js
CHANGED
|
@@ -697,6 +697,7 @@ describe('XtkCaster', function() {
|
|
|
697
697
|
expect(XtkCaster._variantStorageAttribute("")).toBe(null);
|
|
698
698
|
expect(XtkCaster._variantStorageAttribute(6)).toBe("stringValue");
|
|
699
699
|
expect(XtkCaster._variantStorageAttribute("string")).toBe("stringValue");
|
|
700
|
+
expect(XtkCaster._variantStorageAttribute("primarykey")).toBe("stringValue");
|
|
700
701
|
expect(XtkCaster._variantStorageAttribute("int64")).toBe("stringValue");
|
|
701
702
|
expect(XtkCaster._variantStorageAttribute("uuid")).toBe("stringValue");
|
|
702
703
|
expect(XtkCaster._variantStorageAttribute(12)).toBe("memoValue");
|
|
@@ -815,6 +816,67 @@ describe('XtkCaster', function() {
|
|
|
815
816
|
});
|
|
816
817
|
})
|
|
817
818
|
|
|
819
|
+
describe("Primarykey type", () => {
|
|
820
|
+
it("Should parse empty primary keys", () => {
|
|
821
|
+
expect(XtkCaster.asPrimaryKey(null)).toBeUndefined();
|
|
822
|
+
expect(XtkCaster.asPrimaryKey(undefined)).toBeUndefined();
|
|
823
|
+
expect(XtkCaster.asPrimaryKey("")).toBeUndefined();
|
|
824
|
+
// no schema
|
|
825
|
+
expect(XtkCaster.asPrimaryKey("|")).toBeUndefined();
|
|
826
|
+
expect(XtkCaster.asPrimaryKey("|xyz")).toBeUndefined();
|
|
827
|
+
});
|
|
828
|
+
|
|
829
|
+
it("Should parse simple keys", () => {
|
|
830
|
+
expect(XtkCaster.asPrimaryKey("xtk:operator|123")).toMatchObject({ schemaId: "xtk:operator", values: [ "123" ] });
|
|
831
|
+
expect(XtkCaster.asPrimaryKey("xtk:operator|")).toMatchObject({ schemaId: "xtk:operator", values: [ "" ] });
|
|
832
|
+
});
|
|
833
|
+
|
|
834
|
+
it("Should parse composite keys", () => {
|
|
835
|
+
expect(XtkCaster.asPrimaryKey("xtk:operator|123|xyz")).toMatchObject({ schemaId: "xtk:operator", values: [ "123", "xyz" ] });
|
|
836
|
+
expect(XtkCaster.asPrimaryKey("xtk:operator||xyz")).toMatchObject({ schemaId: "xtk:operator", values: [ "", "xyz" ] });
|
|
837
|
+
expect(XtkCaster.asPrimaryKey("xtk:operator||xyz|")).toMatchObject({ schemaId: "xtk:operator", values: [ "", "xyz", "" ] });
|
|
838
|
+
});
|
|
839
|
+
|
|
840
|
+
it("Should handle escaping", () => {
|
|
841
|
+
expect(XtkCaster.asPrimaryKey("xtk:operator|a\\|b")).toMatchObject({ schemaId: "xtk:operator", values: [ "a|b" ] });
|
|
842
|
+
expect(XtkCaster.asPrimaryKey("xtk:operator|a\\|b\\|c")).toMatchObject({ schemaId: "xtk:operator", values: [ "a|b|c" ] });
|
|
843
|
+
expect(XtkCaster.asPrimaryKey("xtk:operator|a\\\"b")).toMatchObject({ schemaId: "xtk:operator", values: [ "a\"b" ] });
|
|
844
|
+
expect(XtkCaster.asPrimaryKey("xtk:operator|a\\|b\\\"c")).toMatchObject({ schemaId: "xtk:operator", values: [ "a|b\"c" ] });
|
|
845
|
+
});
|
|
846
|
+
|
|
847
|
+
it("Should convert to string", () => {
|
|
848
|
+
expect(XtkCaster.asString({})).toBe("");
|
|
849
|
+
expect(XtkCaster.asString({ schemaId: "xtk:operator", values: [ "123" ] })).toBe("xtk:operator|123");
|
|
850
|
+
expect(XtkCaster.asString({ schemaId: "xtk:operator", values: [ "123", "xyz" ] })).toBe("xtk:operator|123|xyz");
|
|
851
|
+
expect(XtkCaster.asString({ schemaId: "xtk:operator", values: [ "123", "" ] })).toBe("xtk:operator|123|");
|
|
852
|
+
expect(XtkCaster.asString({ schemaId: "xtk:operator", values: [ "123", null ] })).toBe("xtk:operator|123|");
|
|
853
|
+
expect(XtkCaster.asString({ schemaId: "xtk:operator", values: [ "123", undefined ] })).toBe("xtk:operator|123|");
|
|
854
|
+
expect(XtkCaster.asString({ schemaId: "xtk:operator", values: [ "123", 123 ] })).toBe("xtk:operator|123|123");
|
|
855
|
+
expect(XtkCaster.asString({ schemaId: "xtk:operator", values: [ "123", 0 ] })).toBe("xtk:operator|123|0");
|
|
856
|
+
expect(XtkCaster.asString({ schemaId: "xtk:operator", values: [ "123", true ] })).toBe("xtk:operator|123|true");
|
|
857
|
+
expect(XtkCaster.asString({ schemaId: "xtk:operator", values: [ "123", false ] })).toBe("xtk:operator|123|false");
|
|
858
|
+
});
|
|
859
|
+
|
|
860
|
+
it("Should support as()", () => {
|
|
861
|
+
expect(XtkCaster.as({ schemaId: "xtk:operator", values: [ "123" ] }, "string")).toBe("xtk:operator|123");
|
|
862
|
+
expect(XtkCaster.as({ schemaId: "xtk:operator", values: [ "123" ] }, "primarykey")).toMatchObject({ schemaId: "xtk:operator", values: [ "123" ] });
|
|
863
|
+
expect(XtkCaster.as("xtk:operator|123", "primarykey")).toMatchObject({ schemaId: "xtk:operator", values: [ "123" ] });
|
|
864
|
+
});
|
|
865
|
+
|
|
866
|
+
it("Should test primary key type", () => {
|
|
867
|
+
expect(XtkCaster.isPrimaryKey(undefined)).toBe(false);
|
|
868
|
+
expect(XtkCaster.isPrimaryKey(null)).toBe(false);
|
|
869
|
+
expect(XtkCaster.isPrimaryKey("")).toBe(false);
|
|
870
|
+
expect(XtkCaster.isPrimaryKey(0)).toBe(false);
|
|
871
|
+
expect(XtkCaster.isPrimaryKey(123)).toBe(false);
|
|
872
|
+
expect(XtkCaster.isPrimaryKey({ schemaId: "nms:recipient" })).toBe(false);
|
|
873
|
+
expect(XtkCaster.isPrimaryKey({ schemaId: "nms:recipient", values:null })).toBe(false);
|
|
874
|
+
expect(XtkCaster.isPrimaryKey({ schemaId: "nms:recipient", values:"123" })).toBe(false);
|
|
875
|
+
expect(XtkCaster.isPrimaryKey({ schemaId: "nms:recipient", values:[ "123" ]})).toBe(true);
|
|
876
|
+
expect(XtkCaster.isPrimaryKey({ schemaId: "nms:recipient", values:[ ]})).toBe(true);
|
|
877
|
+
});
|
|
878
|
+
});
|
|
879
|
+
|
|
818
880
|
it("Should check time type", () => {
|
|
819
881
|
expect(XtkCaster.isTimeType(null)).toBe(false);
|
|
820
882
|
expect(XtkCaster.isTimeType(undefined)).toBe(false);
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2022 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/**********************************************************************************
|
|
15
|
+
*
|
|
16
|
+
* Unit tests for the xtk:persist interface (CRUD operations)
|
|
17
|
+
*
|
|
18
|
+
*********************************************************************************/
|
|
19
|
+
const Mock = require('./mock.js').Mock;
|
|
20
|
+
|
|
21
|
+
describe('xtk:persist interface', function () {
|
|
22
|
+
|
|
23
|
+
describe("create", () => {
|
|
24
|
+
it("Should create an object", async () => {
|
|
25
|
+
const client = await Mock.makeClient();
|
|
26
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
27
|
+
await client.NLWS.xtkSession.logon();
|
|
28
|
+
|
|
29
|
+
const delivery = client.NLWS.nmsDelivery.create({ label: "Hello" });
|
|
30
|
+
expect(delivery.__xtkProxy).toBe(true);
|
|
31
|
+
expect(delivery.inspect()).toMatchObject({ label: "Hello" });
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("Should support missing argument", async () => {
|
|
35
|
+
const client = await Mock.makeClient();
|
|
36
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
37
|
+
await client.NLWS.xtkSession.logon();
|
|
38
|
+
|
|
39
|
+
const delivery = client.NLWS.nmsDelivery.create();
|
|
40
|
+
expect(delivery.__xtkProxy).toBe(true);
|
|
41
|
+
expect(delivery.inspect()).toMatchObject({ });
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe("NewInstance", () => {
|
|
46
|
+
|
|
47
|
+
it("Should create a new delivery instance", async () => {
|
|
48
|
+
const client = await Mock.makeClient();
|
|
49
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
50
|
+
await client.NLWS.xtkSession.logon();
|
|
51
|
+
|
|
52
|
+
// Create the proxy object
|
|
53
|
+
const delivery = client.NLWS.nmsDelivery.create({ label: "Hello" });
|
|
54
|
+
|
|
55
|
+
// Calling NewInstance will load the nms:delivery schema. As this schema
|
|
56
|
+
// implements the xtk:persist interface, it will first load xtk:session
|
|
57
|
+
client._transport.mockReturnValueOnce(Mock.GET_NMS_DELIVERY_SCHEMA_RESPONSE);
|
|
58
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_SESSION_SCHEMA_RESPONSE);
|
|
59
|
+
client._transport.mockReturnValueOnce(Mock.GET_DELIVERY_NEW_INSTANCE_RESPONSE);
|
|
60
|
+
await delivery.newInstance();
|
|
61
|
+
|
|
62
|
+
expect(client._transport).toHaveBeenCalledTimes(4);
|
|
63
|
+
expect(client._transport.mock.calls[1][0].data).toMatch("xtk:schema|nms:delivery"); // first we fetched the delivery schema
|
|
64
|
+
expect(client._transport.mock.calls[2][0].data).toMatch("xtk:schema|xtk:session"); // this triggered a fetch of the session schema
|
|
65
|
+
expect(client._transport.mock.calls[3][0].data).toMatch("urn:xtk:persist|nms:delivery"); // now we're calling the interface method
|
|
66
|
+
expect(client._transport.mock.calls[3][0].data).toMatch("xtkschema=\"nms:delivery\""); // and which should have the xtkschema set
|
|
67
|
+
const result = await client._transport.mock.results[3].value;
|
|
68
|
+
expect(result).toMatch("<folder _cs=\"Delivery templates\"/>");
|
|
69
|
+
|
|
70
|
+
// Calling another non-static method on the delivery
|
|
71
|
+
client._transport.mockReturnValueOnce(Mock.GET_DELIVERY_TEST_RESPONSE);
|
|
72
|
+
await delivery.test();
|
|
73
|
+
expect(client._transport).toHaveBeenCalledTimes(5);
|
|
74
|
+
expect(client._transport.mock.calls[4][0].data).toMatch("<folder _cs=\"Delivery templates\"/>"); // Call should have the result of new instance as first parameter
|
|
75
|
+
expect(client._transport.mock.calls[4][0].data).toMatch("xtkschema=\"nms:delivery\""); // and also have the xtkschema attribute set
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("Should support passing an xtk proxy in stead of a DOM document", async () => {
|
|
79
|
+
const client = await Mock.makeClient();
|
|
80
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
81
|
+
await client.NLWS.xtkSession.logon();
|
|
82
|
+
const delivery = client.NLWS.nmsDelivery.create({ label: "Hello" });
|
|
83
|
+
|
|
84
|
+
client._transport.mockReturnValueOnce(Mock.GET_XTK_SESSION_SCHEMA_RESPONSE);
|
|
85
|
+
client._transport.mockReturnValueOnce(Promise.resolve(`<?xml version='1.0'?><SOAP-ENV:Envelope xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:ns='urn:wpp:default' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
|
|
86
|
+
<SOAP-ENV:Body>
|
|
87
|
+
<WriteResponse xmlns='urn:wpp:default' SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>
|
|
88
|
+
</WriteResponse>
|
|
89
|
+
</SOAP-ENV:Body>
|
|
90
|
+
</SOAP-ENV:Envelope>`));
|
|
91
|
+
await client.NLWS.xtkSession.write(delivery);
|
|
92
|
+
expect(client._transport).toHaveBeenCalledTimes(3);
|
|
93
|
+
expect(client._transport.mock.calls[2][0].data).toMatch("label=\"Hello\""); // entity proxy has been correctly serialized
|
|
94
|
+
})
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
});
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2022 Adobe. All rights reserved.
|
|
3
|
+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
|
|
7
|
+
Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/**********************************************************************************
|
|
15
|
+
*
|
|
16
|
+
* Unit tests for the xtk proxies
|
|
17
|
+
* A xtk proxy is an javascript Proxy object returned by the SDK create() function
|
|
18
|
+
*
|
|
19
|
+
* The proxy object intercept method calls and transforms them into async API calls.
|
|
20
|
+
*
|
|
21
|
+
*********************************************************************************/
|
|
22
|
+
const Mock = require('./mock.js').Mock;
|
|
23
|
+
|
|
24
|
+
let client = undefined;
|
|
25
|
+
|
|
26
|
+
beforeAll(async () => {
|
|
27
|
+
client = await Mock.makeClient();
|
|
28
|
+
client._transport.mockReturnValueOnce(Mock.LOGON_RESPONSE);
|
|
29
|
+
await client.NLWS.xtkSession.logon();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
describe('xtk proxies', function () {
|
|
33
|
+
|
|
34
|
+
it("Should create objects", async () => {
|
|
35
|
+
const delivery = client.NLWS.nmsDelivery.create({ label: "Hello" });
|
|
36
|
+
expect(delivery.__xtkProxy).toBe(true); // proxy have the __xtkProxy property
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("Should has schemaId", async () => {
|
|
40
|
+
const delivery = client.NLWS.nmsDelivery.create({ label: "Hello" });
|
|
41
|
+
expect(delivery["."].schemaId).toBe("nms:delivery"); // ["."] is the call context
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("Should return the underlying object", async () => {
|
|
45
|
+
const delivery = client.NLWS.nmsDelivery.create({ label: "Hello" });
|
|
46
|
+
expect(delivery["."].object).toMatchObject({ label: "Hello" });
|
|
47
|
+
expect(delivery.entity).toMatchObject({ label: "Hello" });
|
|
48
|
+
expect(delivery.inspect()).toMatchObject({ label: "Hello" });
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("Should allow to get properties", () => {
|
|
52
|
+
const delivery = client.NLWS.nmsDelivery.create({ label: "Hello" });
|
|
53
|
+
expect(delivery.entity.label).toBe("Hello");
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("Should allow to set properties", () => {
|
|
57
|
+
const delivery = client.NLWS.nmsDelivery.create({ label: "Hello" });
|
|
58
|
+
delivery.label = "World";
|
|
59
|
+
expect(delivery.entity.label).toBe("World");
|
|
60
|
+
delivery.entity.label = "Hello World";
|
|
61
|
+
expect(delivery.entity.label).toBe("Hello World");
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("Should have a save method", async () => {
|
|
65
|
+
const delivery = client.NLWS.nmsDelivery.create({ label: "Hello" });
|
|
66
|
+
// The save method is simmply a proxy to xtk:session#Write
|
|
67
|
+
const mockWrite = jest.fn();
|
|
68
|
+
delivery["."].client = { NLWS: { xtkSession: { write: mockWrite } } };
|
|
69
|
+
await delivery.save();
|
|
70
|
+
expect(mockWrite).toHaveBeenCalledWith(delivery.entity);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("Should proxy function calls to API calls", async () => {
|
|
74
|
+
const delivery = client.NLWS.nmsDelivery.create({ label: "Hello" });
|
|
75
|
+
const mockCallMethod = jest.fn();
|
|
76
|
+
delivery["."].client = { _callMethod: mockCallMethod };
|
|
77
|
+
await delivery.myCall("Hello");
|
|
78
|
+
expect(mockCallMethod).toHaveBeenCalledWith("MyCall", delivery["."], [ "Hello" ]);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
});
|