forked from newagebegins/BattleCity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtilsSpec.js
35 lines (30 loc) · 1.04 KB
/
UtilsSpec.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
describe("arrayContains", function () {
it("should tell if an array contains an object", function () {
var object1 = {field: 'value'};
var object2 = {field2: 'value2'};
var object3 = {field: 'value'};
var a = [1, 'b', 3, object1];
expect(arrayContains(a, 1)).toBeTruthy();
expect(arrayContains(a, 'b')).toBeTruthy();
expect(arrayContains(a, object1)).toBeTruthy();
expect(arrayContains(a, 2)).toBeFalsy();
expect(arrayContains(a, object2)).toBeFalsy();
expect(arrayContains(a, object3)).toBeFalsy();
expect(arrayContains(a, 'c')).toBeFalsy();
});
});
describe("arrayRemove", function () {
it("should remove an object from an array", function () {
var object1 = {field: 'value'};
var a = [1, 'b', 3, object1];
arrayRemove(a, object1);
expect(a).toEqual([1, 'b', 3]);
arrayRemove(a, 'b');
expect(a).toEqual([1, 3]);
});
});
describe("String", function () {
it("#lpad", function () {
expect("1".lpad(" ", 2)).toEqual(" 1");
});
});