forked from atlassian/techradar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinputSanitizer-spec.js
50 lines (40 loc) · 1.57 KB
/
inputSanitizer-spec.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
44
45
46
47
48
49
50
const InputSanitizer = require('../../src/util/inputSanitizer');
describe('InputSanitizer', function(){
var sanitizer, rawBlip, blip;
beforeAll(function(){
sanitizer = new InputSanitizer();
var description = "<b>Hello</b> <script>alert('dangerous');</script>there <h1>heading</h1>";
rawBlip = {
name: "Hello <script>alert('dangerous');</script>there <h1>blip</h1>",
description: description,
ring: '<a href="/asd">Adopt</a>',
quadrant: '<strong>techniques & tools</strong>',
isNew: 'true<br>'
};
blip = sanitizer.sanitize(rawBlip);
});
it('strips out script tags from blip descriptions', function(){
expect(blip.description).toEqual("<b>Hello</b> there <h1>heading</h1>");
});
it('strips out all tags from blip name', function(){
expect(blip.name).toEqual("Hello there blip");
});
it('strips out all tags from blip status', function(){
expect(blip.isNew).toEqual("true");
});
it('strips out all tags from blip ring', function(){
expect(blip.ring).toEqual("Adopt");
});
it('strips out all tags from blip quadrant', function(){
expect(blip.quadrant).toEqual("techniques & tools");
});
it('trims white spaces in keys and values', function() {
rawBlip = {
' name': ' Some name ',
' ring ': ' Some ring name ',
};
blip = sanitizer.sanitize(rawBlip);
expect(blip.name).toEqual('Some name');
expect(blip.ring).toEqual('Some ring name');
});
});