Skip to content

Commit

Permalink
Cover last lines in unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
9larsons committed Oct 29, 2024
1 parent 2fc2c6a commit 253608a
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion ghost/email-service/test/email-renderer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ describe('Email renderer', function () {
};
});

it('handles dates when the locale is en', function () {
it('handles dates when the locale is en-gb (default)', function () {
const html = '%%{created_at}%%';
const replacements = emailRenderer.buildReplacementDefinitions({html, newsletterUuid: newsletter.get('uuid')});
assert.equal(replacements.length, 2);
Expand Down Expand Up @@ -427,6 +427,34 @@ describe('Email renderer', function () {
assert.equal(replacements[0].id, 'created_at');
assert.equal(replacements[0].getValue(member), '13 mars 2023');
});
it('handles dates when the locale is en (US)', function () {
emailRenderer = new EmailRenderer({
urlUtils: {
urlFor: () => 'http://example.com/subdirectory/'
},
labs: {
isSet: () => labsEnabled
},
settingsCache: {
get: (key) => {
if (key === 'timezone') {
return 'UTC';
}
if (key === 'locale') {
return 'en';
}
}
},
settingsHelpers: {getMembersValidationKey,createUnsubscribeUrl},
t: t
});
const html = '%%{created_at}%%';
const replacements = emailRenderer.buildReplacementDefinitions({html, newsletterUuid: newsletter.get('uuid')});
assert.equal(replacements.length, 2);
assert.equal(replacements[0].token.toString(), '/%%\\{created_at\\}%%/g');
assert.equal(replacements[0].id, 'created_at');
assert.equal(replacements[0].getValue(member), '13 March 2023');
});
});
describe('isMemberTrialing', function () {
let emailRenderer;
Expand Down

0 comments on commit 253608a

Please sign in to comment.