-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
html.js
36 lines (30 loc) · 1.09 KB
/
html.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*!
* template-helpers <https://github.com/jonschlinkert/template-helpers>
*
* Copyright (c) 2015, Jon Schlinkert.
* Licensed under the MIT License.
*/
'use strict';
var assert = require('assert');
var helpers = require('..')('html');
var template = require('lodash.template');
var imports = {imports: helpers};
describe('html', function() {
describe('escapeHtml', function() {
it('should return an empty string when undefined.', function() {
assert.equal(template('<%= escapeHtml() %>', imports)(), '');
});
it('should return create a code example from the given file.', function() {
assert.equal(template('<%= escapeHtml("<span>foo</span>") %>', imports)(), '<span>foo</span>');
});
});
describe('sanitize', function() {
it('should return an empty string when undefined.', function() {
assert.equal(template('<%= sanitize() %>', imports)(), '');
});
it('should strip html from a string.', function() {
var actual = template('<%= sanitize("<span>foo</span>") %>', imports)();
assert.equal(actual, 'foo');
});
});
});