forked from playcanvas/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_string.js
More file actions
41 lines (32 loc) · 1.02 KB
/
test_string.js
File metadata and controls
41 lines (32 loc) · 1.02 KB
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
module('pc.string');
test("format: No args", function() {
var src = "a string";
var expected = src;
var result = pc.string.format(src);
equal(result, expected);
});
test("format: one arg", function() {
var src = "a string {0}";
var expected = "a string abc";
var result = pc.string.format(src, "abc");
equal(result, expected);
});
test("format: two args", function() {
var src = "{0} a string {1}";
var expected = "abc a string def";
var result = pc.string.format(src, "abc", "def");
equal(result, expected);
});
test("toBool: strict", function () {
strictEqual(true, pc.string.toBool("true", true));
strictEqual(false, pc.string.toBool("false", true));
throws(function () {
pc.string.toBool("abc", true);
}, Error);
});
test("toBool: non-strict", function () {
strictEqual(true, pc.string.toBool("true"));
strictEqual(false, pc.string.toBool("false"));
strictEqual(false, pc.string.toBool("abc"));
strictEqual(false, pc.string.toBool(undefined));
});