From 81c6af77b57f69e79be974d8c8c13878eb506af5 Mon Sep 17 00:00:00 2001 From: Naz Date: Wed, 4 May 2022 16:42:36 +0800 Subject: [PATCH] Fixed unit test coverage refs https://github.com/TryGhost/Toolbox/issues/292 - With the package being out of TryGhost/Ghost codebase the paths have changed and needed to introdude a concept of "fixtures" for the package to be able to funciton independently --- .../test/email-content-generator.test.js | 6 +- .../test/fixtures/templates/newsletter.html | 876 ++++++++++++++++++ .../test/fixtures/templates/welcome.html | 161 ++++ 3 files changed, 1040 insertions(+), 3 deletions(-) create mode 100644 ghost/email-content-generator/test/fixtures/templates/newsletter.html create mode 100644 ghost/email-content-generator/test/fixtures/templates/welcome.html diff --git a/ghost/email-content-generator/test/email-content-generator.test.js b/ghost/email-content-generator/test/email-content-generator.test.js index 852dd39f0a..6186a2e414 100644 --- a/ghost/email-content-generator/test/email-content-generator.test.js +++ b/ghost/email-content-generator/test/email-content-generator.test.js @@ -1,14 +1,14 @@ const assert = require('assert'); const path = require('path'); -const EmailContentGenerator = require('../../../../../core/server/services/mail/EmailContentGenerator'); +const EmailContentGenerator = require('../index'); describe('Mail: EmailContentGenerator', function () { it('generate welcome', async function () { const emailContentGenerator = new EmailContentGenerator({ getSiteTitle: () => 'The Ghost Blog', getSiteUrl: () => 'http://myblog.com', - templatesDir: path.resolve(__dirname, '../../../../../core/server/services/mail/templates/') + templatesDir: path.resolve(__dirname, './fixtures/templates/') }); const content = await emailContentGenerator.getContent({ @@ -29,7 +29,7 @@ describe('Mail: EmailContentGenerator', function () { const emailContentGenerator = new EmailContentGenerator({ getSiteTitle: () => 'The Ghost Blog', getSiteUrl: () => 'http://myblog.com', - templatesDir: path.resolve(__dirname, '../../../../../core/server/services/mail/templates/') + templatesDir: path.resolve(__dirname, './fixtures/templates/') }); const content = await emailContentGenerator.getContent({ diff --git a/ghost/email-content-generator/test/fixtures/templates/newsletter.html b/ghost/email-content-generator/test/fixtures/templates/newsletter.html new file mode 100644 index 0000000000..ab2e625148 --- /dev/null +++ b/ghost/email-content-generator/test/fixtures/templates/newsletter.html @@ -0,0 +1,876 @@ + + + + + + + + {{blog.title}} + + + + + + + + + +
+
+ + + + + + +
+ + + + + + + + +
+ + + + +
+ + + + + + +
 
+
+
+ + + <% if (blog.logo) { %> + + + + + + +
+ + + + +
+
+ + +
+
+
+ <% } %> + + + + + + + +
+ + + + +
+ + + + + + +
 
+
+
+ + + + + + +
+ + + + +
+ +

+ {{blog.title}} +

+
+
+ + + + + + +
+ + + + +
+ + + + + + +
 
+
+
+ + + + + + +
+ + + + +
+ +

+ {{newsletter.interval}} digest — + {{newsletter.date}}

+ +
+
+ + + + + + +
+ + + + +
+ + + + + + +
 
+
+
+ + + + + + <% if (blog.post[0].picture) { %> + + + + + + +
+ + + + +
+
+ + Feature Image
+
+
+ <% } %> + + + + + + + + +
+ + + + +
+ + + + + <% if (blog.post[0].picture) { %> + + <% } else { %> +
+ <% } %> + + + + + + + + + +
+ + + + +
 
+
+ + + + +
+ + + + + + +
+ + + + +
+ + + + + + +
 
+
+
+ + + + + + +
+ + + + +
+ + +

+ + {{blog.post[0].title}} + +

+
+
+ + + + + + +
+ + + + +
+ + + + + + +
 
+
+
+ + + + + + +
+ + + + +
+ + +

+ {{blog.post[0].text}} +

+
+
+ + + + + + +
+ + + + +
+ + + + + + +
 
+
+
+ + + + + + +
+ + + + +
+ + + + + + +
+ + + + +
+
+ + Read More + +
+
+
+
+
+ + + + + + +
+ + + + +
+ + + + + + +
 
+
+
+
+
+ + + + +
 
+
+ +
+
+ + + + + + + + +
+ + + + +
+ + + + + + +
 
+
+
+ + + + <% if (blog.post.length > 1) { %> + + + + + + + + +
+ + + + +
 
+
+ + + + +
+ +

+ {{blog.post[1].tag}} / {{blog.post[1].author}} +

+ + + + + + +
 
+ +

+ + {{blog.post[1].title}} + +

+ + + + + + +
 
+ +

+ {{blog.post[1].text}} +

+
+
+ + + + +
 
+
+ + + + + + +
+ + + + +
+ + + + + + +
 
+
+
+ + <% if (blog.post.length > 2) { %> + + + + + + + + +
+ + + + +
 
+
+ + + + +
+ +

+ {{blog.post[2].tag}} / {{blog.post[2].author}} +

+ + + + + + +
 
+ +

+ + {{blog.post[2].title}} + +

+ + + + + + +
 
+ +

+ {{blog.post[2].text}} +

+
+
+ + + + +
 
+
+ + + + + + +
+ + + + +
+ + + + + + +
 
+
+
+ + + <% if (blog.post.length > 3) { %> + + <% for (var i = 3; i < blog.post.length; i++) { %> + + + + + + + + +
+ + + + +
 
+
+ + + + +
+ +

+ {{blog.post[i]['tag']}} / {{blog.post[i]['author']}} +

+ + + + + + +
 
+ +

+ + {{blog.post[i]['title']}} + +

+ + + + + + +
 
+ +

+ {{blog.post[i]['text']}} +

+
+
+ + + + +
 
+
+ + + <% if (i < blog.post.length-1) { %> + + + + + + +
+ + + + +
+ + + + + + +
 
+
+
+ <% } %> + + <% } %> + + + + + + + + + +
+ + + + +
+ + + + + + +
+ + + + +
+ + + + + + +
 
+
+
+ + + + + + + + +
+ + + + +
 
+
+ + + + +
+ + + + + + +
+ + + + +
+
+ + Find more on {{blog.title}} +
+
+
+
+
+ + + + +
 
+
+ + + + + + +
+ + + + +
+ + + + + + +
 
+ + +
+
+ + + + + + +
+ + + + +
+ + + + + + +
 
+
+
+
+
+ <% } %> + + <% } %> + + <% } %> + + + + + + + + +
+ + + + +
+ +

+ You’re receiving this email because you subscribed to {{newsletter.interval}} emails from {{blog.title}}
If you’d prefer not to receive these, you can + + unsubscribe instantly + . +

+
+
+ + + + + + +
+ + + + +
+ + + + + + +
 
+
+
+ + +
+
+
+ +
                                                           
+ + diff --git a/ghost/email-content-generator/test/fixtures/templates/welcome.html b/ghost/email-content-generator/test/fixtures/templates/welcome.html new file mode 100644 index 0000000000..d41a86c108 --- /dev/null +++ b/ghost/email-content-generator/test/fixtures/templates/welcome.html @@ -0,0 +1,161 @@ + + + + + +Welcome to Ghost + + + + + + + + + + +
  + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + +
+

Hello!

+
+

Good news! You've successfully created a brand new Ghost publication over on {{ siteUrl }}

+

You can log in to your admin account with the following details:

+

Email Address: {{ownerEmail}}

+

Password: The password you chose when you signed up

+ +

Keep this email somewhere safe for future reference, and have fun!

+

xoxo

+

Team Ghost – https://ghost.org

+
+
+ +
+ + +
+
 
+ + \ No newline at end of file