-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsampleTests.js
51 lines (38 loc) · 1.04 KB
/
sampleTests.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
var Thing = function() {};
Thing.prototype.error = function () {
throw new Error;
};
var ObjectUnderTest = function() {}
ObjectUnderTest.prototype.sayhello= function () {
return 'hello';
};
ObjectUnderTest.prototype.saybye = function () {
return 'bye';
};
describe('Sample Tests', function() {
it('checks to toBeDefined matcher', function() {
var thing = new Thing();
expect(thing).toBeDefined();
});
it('checks toEqual matcher', function() {
expect(3).toEqual("3");
});
it('checks toBe matcher', function() {
expect(3).toBe(3);
});
it('checks toContain matcher', function() {
expect([1,2,"3"]).toContain("3");
});
it('checks toBeNull matcher', function() {
expect(null).toBeNull();
});
it('checks toThrowError matcher', function() {
var thing = new Thing();
var other;
expect(thing.error()).toThrowError(new Error);
});
it('checks if spy is working', function() {
Iggy(ObjectUnderTest, 'sayhello').andReturn('hello')
expect(ObjectUnderTest.sayhello()).toEqual('hello');
});
});