Skip to content

Commit 8f0d3cd

Browse files
fix tests
1 parent 7f3e8c2 commit 8f0d3cd

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

test/templateTests.js

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,19 @@ const {
3131

3232
let ACCOUNT_ID;
3333
let ACCESS_TOKEN;
34-
let TEMPLATE_ID;
34+
let TEMPLATE_ID = '';
35+
36+
const createTestTemplate = async(newTemplateName) => {
37+
const args = {
38+
accessToken: ACCESS_TOKEN,
39+
basePath: BASE_PATH,
40+
accountId: ACCOUNT_ID,
41+
templateName: newTemplateName,
42+
docFile: TEST_TEMPLATE_PDF_FILE
43+
};
44+
45+
return await createTemplate(args);
46+
}
3547

3648
describe ('TemplatesApi tests:', function() {
3749
before(async function() {
@@ -48,17 +60,8 @@ describe ('TemplatesApi tests:', function() {
4860

4961
it('createTemplate method should create the correct template definition if correct data is provided', async function() {
5062
this.timeout(TEST_TIMEOUT_MS);
51-
5263
const newTemplateName = `${TEMPLATE_NAME}_${Date.now()}`;
53-
const args = {
54-
accessToken: ACCESS_TOKEN,
55-
basePath: BASE_PATH,
56-
accountId: ACCOUNT_ID,
57-
templateName: newTemplateName,
58-
docFile: TEST_TEMPLATE_PDF_FILE
59-
};
60-
61-
const { templateId, templateName, createdNewTemplate } = await createTemplate(args);
64+
const { templateId, templateName, createdNewTemplate } = await createTestTemplate(newTemplateName);
6265

6366
TEMPLATE_ID = templateId;
6467

@@ -263,8 +266,10 @@ describe ('TemplatesApi tests:', function() {
263266
it('useTemplate method should create the envelope with template if correct data is provided', async function() {
264267
this.timeout(TEST_TIMEOUT_MS);
265268

269+
const newTemplateName = `${TEMPLATE_NAME}_${Date.now()}`;
270+
const { templateId } = await createTestTemplate(newTemplateName);
266271
const envelopeArgs = {
267-
templateId: TEMPLATE_ID,
272+
templateId: templateId,
268273
signerEmail: config.signerEmail,
269274
signerName: config.signerName,
270275
ccEmail: CC_EMAIL,
@@ -319,8 +324,10 @@ describe ('TemplatesApi tests:', function() {
319324
it('addDocToTemplate method should correctly add document to a template if correct data is provided', async function() {
320325
this.timeout(TEST_TIMEOUT_MS);
321326

327+
const newTemplateName = `${TEMPLATE_NAME}_${Date.now()}`;
328+
const { templateId } = await createTestTemplate(newTemplateName);
322329
const envelopeArgs = {
323-
templateId: TEMPLATE_ID,
330+
templateId: templateId,
324331
signerEmail: config.signerEmail,
325332
signerName: config.signerName,
326333
signerClientId: signerClientId,

0 commit comments

Comments
 (0)