flectra/addons/mail/static/tests/mail_utils_tests.js

35 lines
981 B
JavaScript

flectra.define('mail.mail_utils_tests', function (require) {
"use strict";
var utils = require('mail.utils');
QUnit.module('mail', {}, function () {
QUnit.module('Mail utils');
QUnit.test('add_link utility function', function (assert) {
assert.expect(7);
var testInputs = {
'http://admin:password@example.com:8/%2020': true,
'https://admin:password@example.com/test': true,
'www.example.com:8/test': true,
'https://127.0.0.5:8069': true,
'www.127.0.0.5': false,
'should.notmatch': false,
'fhttps://test.example.com/test': false,
};
_.each(testInputs, function (willLinkify, content) {
var output = utils.parse_and_transform(content, utils.add_link);
if (willLinkify) {
assert.strictEqual(output.indexOf('<a '), 0, "There should be a link");
} else {
assert.strictEqual(output.indexOf('<a '), -1, "There should be no link");
}
});
});
});
});