Skip to content

Commit f4ba58e

Browse files
added documents to tests
1 parent d44a243 commit f4ba58e

File tree

2 files changed

+111
-10
lines changed

2 files changed

+111
-10
lines changed

test/envelopeTests.js

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const { sendEnvelopeForEmbeddedSigning, makeEnvelope: makeEnvelopeForEmbeddedSig
77
const { sendEnvelope, makeEnvelope: makeEnvelopeForSigningViaEmail, document1 } = require('../lib/eSignature/examples/signingViaEmail')
88
const fs = require('fs');
99
const path = require('path');
10-
const { authenticate } = require('./testHelpers');
10+
const { authenticate, areEqual } = require('./testHelpers');
1111
const { signerClientId, pingUrl, returnUrl, TEST_PDF_FILE, TEST_DOCX_FILE, BASE_PATH } = require('./constants')
1212

1313
chai.use(chaiExclude);
@@ -63,6 +63,14 @@ describe ('envelopeTests', function() {
6363

6464
const expected = {
6565
emailSubject: "Please sign this document",
66+
documents: [
67+
{
68+
documentBase64: Buffer.from(fs.readFileSync(path.resolve(TEST_PDF_FILE))).toString("base64"),
69+
name: "Lorem Ipsum",
70+
fileExtension: "pdf",
71+
documentId: "3",
72+
}
73+
],
6674
recipients: {
6775
signers: [
6876
{
@@ -89,7 +97,7 @@ describe ('envelopeTests', function() {
8997
const envelope = await makeEnvelopeForEmbeddedSigning(envelopeArgs);
9098

9199
should.exist(envelope);
92-
expect(envelope).excluding('documents').to.deep.equal(expected);
100+
expect(envelope).excluding(['']).to.deep.equal(expected);
93101
});
94102

95103
it('embeddedSigning_makeRecipientView', async function() {
@@ -116,7 +124,6 @@ describe ('envelopeTests', function() {
116124
const viewRequest = await makeRecipientViewRequest(envelopeArgs);
117125

118126
should.exist(viewRequest);
119-
// expect(JSON.stringify(expected)).to.be.equal(JSON.stringify(viewRequest));
120127
expect({...viewRequest}).to.deep.equal({...expected});
121128
});
122129

@@ -147,6 +154,30 @@ describe ('envelopeTests', function() {
147154
it('signViaEmail_makeEnvelope', async function() {
148155
this.timeout(0);
149156

157+
const document1Text = `
158+
<!DOCTYPE html>
159+
<html>
160+
<head>
161+
<meta charset="UTF-8">
162+
</head>
163+
<body style="font-family:sans-serif;margin-left:2em;">
164+
<h1 style="font-family: 'Trebuchet MS', Helvetica, sans-serif;
165+
color: darkblue;margin-bottom: 0;">World Wide Corp</h1>
166+
<h2 style="font-family: 'Trebuchet MS', Helvetica, sans-serif;
167+
margin-top: 0px;margin-bottom: 3.5em;font-size: 1em;
168+
color: darkblue;">Order Processing Division</h2>
169+
<h4>Ordered by ${settings.signerName}</h4>
170+
<p style="margin-top:0em; margin-bottom:0em;">Email: ${settings.signerEmail}</p>
171+
<p style="margin-top:0em; margin-bottom:0em;">Copy to: ${'Test Name'}, ${'[email protected]'}</p>
172+
<p style="margin-top:3em;">
173+
Candy bonbon pastry jujubes lollipop wafer biscuit biscuit. Topping brownie sesame snaps sweet roll pie. Croissant danish biscuit soufflé caramels jujubes jelly. Dragée danish caramels lemon drops dragée. Gummi bears cupcake biscuit tiramisu sugar plum pastry. Dragée gummies applicake pudding liquorice. Donut jujubes oat cake jelly-o. Dessert bear claw chocolate cake gummies lollipop sugar plum ice cream gummies cheesecake.
174+
</p>
175+
<!-- Note the anchor tag for the signature field is in white. -->
176+
<h3 style="margin-top:3em;">Agreed: <span style="color:white;">**signature_1**/</span></h3>
177+
</body>
178+
</html>
179+
`;
180+
150181
const envelopeArgs = {
151182
signerEmail: settings.signerEmail,
152183
signerName: settings.signerName,
@@ -159,6 +190,26 @@ describe ('envelopeTests', function() {
159190

160191
const expected = {
161192
emailSubject: "Please sign this document set",
193+
documents: [
194+
{
195+
documentBase64: Buffer.from(document1Text).toString("base64"),
196+
name: 'Order acknowledgement',
197+
fileExtension: 'html',
198+
documentId: '1',
199+
},
200+
{
201+
documentBase64: Buffer.from(fs.readFileSync(path.resolve(TEST_DOCX_FILE))).toString("base64"),
202+
name: "Battle Plan",
203+
fileExtension: "docx",
204+
documentId: "2",
205+
},
206+
{
207+
documentBase64: Buffer.from(fs.readFileSync(path.resolve(TEST_PDF_FILE))).toString("base64"),
208+
name: "Lorem Ipsum",
209+
fileExtension: "pdf",
210+
documentId: "3",
211+
}
212+
],
162213
recipients: {
163214
signers: [
164215
{
@@ -199,7 +250,7 @@ describe ('envelopeTests', function() {
199250
const envelope = await makeEnvelopeForSigningViaEmail(envelopeArgs);
200251

201252
should.exist(envelope);
202-
expect(envelope).excluding('documents').to.deep.equal(expected);
253+
expect(envelope).excluding(['']).to.deep.equal(expected);
203254
});
204255

205256
it('signViaEmail_document1', async function() {

test/templateTests.js

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const settings = require('../config/appsettings.json');
22
const chai = require('chai');
33
const expect = chai.expect;
44
const should = chai.should();
5-
const helpers = require('./testHelpers');
5+
const fs = require('fs');
66
const { createTemplate, makeTemplate } = require('../lib/eSignature/examples/createTemplate');
77
const { sendEnvelopeFromTemplate, makeEnvelope: makeEnvelopeForUsingTemplate } = require('../lib/eSignature/examples/useTemplate');
88
const { addDocToTemplate, makeEnvelope: makeEnvelopeForAddingDoc, document1: document1ForAddingDoc, makeRecipientViewRequest: makeRecipientViewRequestForAddingDoc } = require('../lib/eSignature/examples/addDocToTemplate')
@@ -219,13 +219,21 @@ describe ('templateTests', function() {
219219
}
220220
]
221221
},
222+
documents: [
223+
{
224+
documentBase64: Buffer.from(fs.readFileSync(TEST_TEMPLATE_PDF_FILE)).toString("base64"),
225+
name: "Lorem Ipsum",
226+
fileExtension: "pdf",
227+
documentId: "1",
228+
}
229+
],
222230
status: "created",
223231
};
224232

225233
const template = await makeTemplate(args);
226234

227235
should.exist(template);
228-
expect(template).excluding('documents').to.deep.equal(expected);
236+
expect(template).excluding(['']).to.deep.equal(expected);
229237
});
230238

231239
it('useTemplate', async function() {
@@ -315,19 +323,47 @@ describe ('templateTests', function() {
315323
it('addDocToTemplate_makeEnvelope', async function() {
316324
this.timeout(0);
317325

326+
const item = 'Item';
327+
const quantity = '5';
328+
318329
const envelopeArgs = {
319330
templateId: TEMPLATE_ID,
320331
signerEmail: settings.signerEmail,
321332
signerName: settings.signerName,
322333
signerClientId: signerClientId,
323334
ccEmail: '[email protected]',
324335
ccName: 'Test Name',
325-
item: 'Item',
326-
quantity: '5',
336+
item: item,
337+
quantity: quantity,
327338
dsReturnUrl: returnUrl,
328339
dsPingUrl: pingUrl
329340
};
330341

342+
const documentText = `
343+
<!DOCTYPE html>
344+
<html>
345+
<head>
346+
<meta charset="UTF-8">
347+
</head>
348+
<body style="font-family:sans-serif;margin-left:2em;">
349+
<h1 style="font-family: 'Trebuchet MS', Helvetica, sans-serif;
350+
color: darkblue;margin-bottom: 0;">World Wide Corp</h1>
351+
<h2 style="font-family: 'Trebuchet MS', Helvetica, sans-serif;
352+
margin-top: 0px;margin-bottom: 3.5em;font-size: 1em;
353+
color: darkblue;">Order Processing Division</h2>
354+
<h4>Ordered by ${settings.signerName}</h4>
355+
<p style="margin-top:0em; margin-bottom:0em;">Email: ${settings.signerEmail}</p>
356+
<p style="margin-top:0em; margin-bottom:0em;">Copy to: ${'Test Name'}, ${'[email protected]'}</p>
357+
<p style="margin-top:3em; margin-bottom:0em;">Item: <b>${item}</b>, quantity: <b>${quantity}</b> at market price.</p>
358+
<p style="margin-top:3em;">
359+
Candy bonbon pastry jujubes lollipop wafer biscuit biscuit. Topping brownie sesame snaps sweet roll pie. Croissant danish biscuit soufflé caramels jujubes jelly. Dragée danish caramels lemon drops dragée. Gummi bears cupcake biscuit tiramisu sugar plum pastry. Dragée gummies applicake pudding liquorice. Donut jujubes oat cake jelly-o. Dessert bear claw chocolate cake gummies lollipop sugar plum ice cream gummies cheesecake.
360+
</p>
361+
<!-- Note the anchor tag for the signature field is in white. -->
362+
<h3 style="margin-top:3em;">Agreed: <span style="color:white;">**signature_1**/</span></h3>
363+
</body>
364+
</html>
365+
`;
366+
331367
const expected = {
332368
compositeTemplates: [
333369
{
@@ -398,6 +434,12 @@ describe ('templateTests', function() {
398434
},
399435
},
400436
],
437+
document: {
438+
documentBase64: Buffer.from(documentText).toString("base64"),
439+
name: "Appendix 1--Sales order",
440+
fileExtension: "html",
441+
documentId: "1",
442+
}
401443
}
402444
],
403445
status: 'sent'
@@ -406,7 +448,7 @@ describe ('templateTests', function() {
406448
const envelope = await makeEnvelopeForAddingDoc(envelopeArgs);
407449

408450
should.exist(envelope);
409-
expect(envelope).excludingEvery('document').to.deep.equal(expected);
451+
expect(envelope).excluding(['']).to.deep.equal(expected);
410452
});
411453

412454
it('addDocToTemplate_document1', async function() {
@@ -590,11 +632,19 @@ describe ('templateTests', function() {
590632
}
591633
]
592634
},
635+
documents: [
636+
{
637+
documentBase64: Buffer.from(fs.readFileSync(TEST_TEMPLATE_DOCX_FILE)).toString("base64"),
638+
name: "Lorem Ipsum",
639+
fileExtension: "docx",
640+
documentId: "1",
641+
}
642+
]
593643
}
594644

595645
const envelope = await makeEnvelopeForSetTabValues(envelopeArgs);
596646

597647
should.exist(envelope);
598-
expect(envelope).excluding('documents').to.deep.equal(expected);
648+
expect(envelope).excluding(['']).to.deep.equal(expected);
599649
});
600650
});

0 commit comments

Comments
 (0)