define(['helpers/sanitizer'], function (sanitizer) {
'use strict';
describe('sanitizer', function () {
describe('sanitizer.addLineBreaks', function () {
it('should add line breaks', function () {
var expectedOutput = 'foo
bar';
var output = sanitizer.addLineBreaks('foo\nbar');
expect(output).toEqual(expectedOutput);
});
});
describe('sanitizer.purifyHtml', function () {
it('should fire up DOMPurify', function () {
var expectedOutput = '123I am a dolphin!';
var output = sanitizer.purifyHtml('123I am a dolphin!');
expect(output).toEqual(expectedOutput);
});
});
describe('sanitizer.purifyText', function () {
it('should escape HTML', function () {
var expectedOutput = '123<a>asd</a>';
var output = sanitizer.purifyText('123asd');
expect(output).toEqual(expectedOutput);
});
});
describe('sanitizer.sanitize', function () {
it('should sanitize a plaintext mail', function () {
var expectedOutput = '123<a>asd</a>';
var output = sanitizer.sanitize({
textPlainBody: '123asd'
});
expect(output).toEqual(expectedOutput);
});
it('should sanitize an html mail', function () {
var expectedOutput = '