mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 02:11:44 +03:00
90cc801394
refs 474e6c4c45
- The method was not easy to understand after skimming through it.
- As we are working on developing a similar pattern for upcoming similar featured created a basic test suited to see input/output relation clearly
35 lines
1.1 KiB
JavaScript
35 lines
1.1 KiB
JavaScript
const should = require('should');
|
|
|
|
const {parseReplacements} = require('../../../../core/server/services/mega/post-email-serializer');
|
|
|
|
describe('Post Email Serializer', function () {
|
|
it('creates replacement pattern for valid format and value', function () {
|
|
const html = '<html>Hey %%{first_name}%%, what is up?</html>';
|
|
const plaintext = 'Hey %%{first_name}%%, what is up?';
|
|
|
|
const replaced = parseReplacements({
|
|
html,
|
|
plaintext
|
|
});
|
|
|
|
replaced.length.should.equal(2);
|
|
replaced[0].format.should.equal('html');
|
|
replaced[0].recipientProperty.should.equal('member_first_name');
|
|
|
|
replaced[1].format.should.equal('plaintext');
|
|
replaced[1].recipientProperty.should.equal('member_first_name');
|
|
});
|
|
|
|
it('does not create replacements for unsupported variable names', function () {
|
|
const html = '<html>Hey %%{last_name}%%, what is up?</html>';
|
|
const plaintext = 'Hey %%{age}%%, what is up?';
|
|
|
|
const replaced = parseReplacements({
|
|
html,
|
|
plaintext
|
|
});
|
|
|
|
replaced.length.should.equal(0);
|
|
});
|
|
});
|