@@ -7,7 +7,7 @@ const { sendEnvelopeForEmbeddedSigning, makeEnvelope: makeEnvelopeForEmbeddedSig
77const { sendEnvelope, makeEnvelope : makeEnvelopeForSigningViaEmail , document1 } = require ( '../lib/eSignature/examples/signingViaEmail' )
88const fs = require ( 'fs' ) ;
99const path = require ( 'path' ) ;
10- const { authenticate } = require ( './testHelpers' ) ;
10+ const { authenticate, areEqual } = require ( './testHelpers' ) ;
1111const { signerClientId, pingUrl, returnUrl, TEST_PDF_FILE , TEST_DOCX_FILE , BASE_PATH } = require ( './constants' )
1212
1313chai . 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' } , ${ 'test@mail.com' } </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 ( ) {
0 commit comments