Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
81155 views
1
/**
2
* Copyright 2013-2014, Facebook, Inc.
3
* All rights reserved.
4
*
5
* This source code is licensed under the BSD-style license found in the
6
* LICENSE file in the root directory of this source tree. An additional grant
7
* of patent rights can be found in the PATENTS file in the same directory.
8
*
9
* @emails react-core
10
*/
11
12
"use strict";
13
14
describe('escapeTextForBrowser', function() {
15
16
var escapeTextForBrowser = require('escapeTextForBrowser');
17
18
it('should escape boolean to string', function() {
19
expect(escapeTextForBrowser(true)).toBe('true');
20
expect(escapeTextForBrowser(false)).toBe('false');
21
});
22
23
it('should escape object to string', function() {
24
var escaped = escapeTextForBrowser({
25
toString: function() {
26
return 'ponys';
27
}
28
});
29
30
expect(escaped).toBe('ponys');
31
});
32
33
it('should escape number to string', function() {
34
expect(escapeTextForBrowser(42)).toBe('42');
35
});
36
37
it('should escape string', function() {
38
var escaped = escapeTextForBrowser('<script type=\'\' src=""></script>');
39
expect(escaped).not.toContain('<');
40
expect(escaped).not.toContain('>');
41
expect(escaped).not.toContain('\'');
42
expect(escaped).not.toContain('\"');
43
44
escaped = escapeTextForBrowser('&');
45
expect(escaped).toBe('&amp;');
46
});
47
48
});
49
50