-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefinedSpec.js
56 lines (43 loc) · 1.49 KB
/
definedSpec.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
51
52
53
54
55
56
var defined = require("../src/util/defined.js");
describe("defined", function() {
it("should return true for an empty object that is defined", function() {
var test = {};
expect(defined(test)).toBe(true);
});
it("should return true for an object that is defined", function() {
var test = { test : "test" };
expect(defined(test)).toBe(true);
});
it("should return true for an integer that is defined", function() {
var test = 1;
expect(defined(test)).toBe(true);
});
it("should return true for an float that is defined", function() {
var test = 1.5;
expect(defined(test)).toBe(true);
});
it("should return true for an empty array that is defined", function() {
var test = [];
expect(defined(test)).toBe(true);
});
it("should return true for an array that is defined", function() {
var test = [2, 4, 'hello', 'world'];
expect(defined(test)).toBe(true);
});
it("should return true for an boolean that is defined", function() {
var test = false;
expect(defined(test)).toBe(true);
});
it("should return false for an uninitialised variable that is defined", function() {
var test;
expect(defined(test)).toBe(false);
});
it("should return false for a null variable that is defined", function() {
var test = null;
expect(defined(test)).toBe(false);
});
it("should return false for a 'undefined' variable that is defined", function() {
var test = undefined;
expect(defined(test)).toBe(false);
});
});