-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
Copy pathstring-test.js
47 lines (37 loc) · 1.53 KB
/
string-test.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
import { moduleFor, AbstractTestCase } from 'internal-test-helpers';
import { SafeString, htmlSafe, isHTMLSafe } from './helpers';
moduleFor(
'SafeString',
class extends AbstractTestCase {
['@test htmlSafe should return an instance of SafeString']() {
let safeString = htmlSafe('you need to be more <b>bold</b>');
this.assert.ok(safeString instanceof SafeString, 'should be a SafeString');
}
['@test htmlSafe should return an empty string for null']() {
let safeString = htmlSafe(null);
this.assert.equal(safeString instanceof SafeString, true, 'should be a SafeString');
this.assert.equal(safeString.toString(), '', 'should return an empty string');
}
['@test htmlSafe should return an instance of SafeString']() {
let safeString = htmlSafe();
this.assert.equal(safeString instanceof SafeString, true, 'should be a SafeString');
this.assert.equal(safeString.toString(), '', 'should return an empty string');
}
}
);
moduleFor(
'SafeString isHTMLSafe',
class extends AbstractTestCase {
['@test isHTMLSafe should detect SafeString']() {
let safeString = htmlSafe('<em>Emphasize</em> the important things.');
this.assert.ok(isHTMLSafe(safeString));
}
['@test isHTMLSafe should not detect SafeString on primatives']() {
this.assert.notOk(isHTMLSafe('Hello World'));
this.assert.notOk(isHTMLSafe({}));
this.assert.notOk(isHTMLSafe([]));
this.assert.notOk(isHTMLSafe(10));
this.assert.notOk(isHTMLSafe(null));
}
}
);