From c342ea14547700aafca18728b39811bfb33292b1 Mon Sep 17 00:00:00 2001 From: Nazar Gargol Date: Wed, 6 Nov 2019 12:54:02 +0700 Subject: [PATCH] Added email data generators in test utils --- core/test/utils/fixtures/data-generator.js | 36 +++++++++++++++++++++- core/test/utils/index.js | 9 ++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/core/test/utils/fixtures/data-generator.js b/core/test/utils/fixtures/data-generator.js index 784c979758..d067179365 100644 --- a/core/test/utils/fixtures/data-generator.js +++ b/core/test/utils/fixtures/data-generator.js @@ -418,6 +418,32 @@ DataGenerator.Content = { type: 'admin', integration_id: undefined // "internal" } + ], + + emails: [ + { + id: ObjectId.generate(), + uuid: '6b6afda6-4b5e-4893-bff6-f16859e8349a', + status: 'sending', + stats: '', + email_count: 2, + subject: 'You got mailed!', + html: '

Look! I\'m an email

', + plaintext: 'Waba-daba-dab-da', + submitted_at: moment().toDate() + }, + { + id: ObjectId.generate(), + uuid: '365daa11-4bf0-4614-ad43-6346387ffa00', + status: 'failed', + error: 'Everything went south', + stats: '', + email_count: 3, + subject: 'You got mailed! Again!', + html: '

What\'s that? Another email!

', + plaintext: 'yes this is an email', + submitted_at: moment().toDate() + } ] }; @@ -425,6 +451,8 @@ DataGenerator.Content = { DataGenerator.Content.subscribers[0].post_id = DataGenerator.Content.posts[0].id; DataGenerator.Content.api_keys[0].integration_id = DataGenerator.Content.integrations[0].id; DataGenerator.Content.api_keys[1].integration_id = DataGenerator.Content.integrations[0].id; +DataGenerator.Content.emails[0].post_id = DataGenerator.Content.posts[0].id; +DataGenerator.Content.emails[1].post_id = DataGenerator.Content.posts[1].id; DataGenerator.forKnex = (function () { function createBasic(overrides) { @@ -904,6 +932,11 @@ DataGenerator.forKnex = (function () { createBasic(DataGenerator.Content.api_keys[2]) ]; + const emails = [ + createBasic(DataGenerator.Content.emails[0]), + createBasic(DataGenerator.Content.emails[1]) + ]; + return { createPost: createPost, createGenericPost: createGenericPost, @@ -940,7 +973,8 @@ DataGenerator.forKnex = (function () { roles_users: roles_users, webhooks: webhooks, integrations: integrations, - api_keys: api_keys + api_keys: api_keys, + emails: emails }; }()); diff --git a/core/test/utils/index.js b/core/test/utils/index.js index 1eef8cf294..b5a0dc2388 100644 --- a/core/test/utils/index.js +++ b/core/test/utils/index.js @@ -464,6 +464,12 @@ fixtures = { return Promise.map(DataGenerator.forKnex.api_keys, function (api_key) { return models.ApiKey.add(api_key, module.exports.context.internal); }); + }, + + insertEmails: function insertEmails() { + return Promise.map(DataGenerator.forKnex.emails, function (email) { + return models.Email.add(email, module.exports.context.internal); + }); } }; @@ -613,6 +619,9 @@ toDoList = { }, api_keys: function insertApiKeys() { return fixtures.insertApiKeys(); + }, + emails: function insertEmails() { + return fixtures.insertEmails(); } };