-
Notifications
You must be signed in to change notification settings - Fork 0
/
filters.strip-tags.js
43 lines (32 loc) · 1.46 KB
/
filters.strip-tags.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
37
38
39
40
41
42
43
var chai = require("chai");
var expect = chai.expect;
var Filter = require("../index");
describe("Filters", function() {
describe("StripTags", function() {
it("should return string without any tags", function(done) {
var StripTags = new Filter.StripTags();
var promise = StripTags.filter("<h1>Hello World!</h1>");
expect(promise).to.be.an.instanceof(Promise);
promise.should.eventually.equal("Hello World!").notify(done);
});
it("should return string with allowed tags only", function(done) {
var StripTags = new Filter.StripTags({
allowedTags: ["h1"]
});
var promise = StripTags.filter("<h1>Test1</h1><h2>Test2</h2><h3>Test3</h3>");
expect(promise).to.be.an.instanceof(Promise);
promise.should.eventually.equal("<h1>Test1</h1>Test2Test3").notify(done);
});
it("should return string with allowed tags and attributes only", function(done) {
var StripTags = new Filter.StripTags({
allowedTags: ["img"],
allowedAttributes: {
"img": ["src"]
}
});
var promise = StripTags.filter("<img src='xxx' alt='yyy' />");
expect(promise).to.be.an.instanceof(Promise);
promise.should.eventually.equal("<img src=\"xxx\" />").notify(done);
});
});
});