-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathtest.js
More file actions
67 lines (48 loc) · 1.34 KB
/
Copy pathtest.js
File metadata and controls
67 lines (48 loc) · 1.34 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
require('./index');
/*
*
*
* INSTRUCTIONS:
* - There are 5 tests that you will need to make pass.
* - FILL_ME_IN -> fill in the value you expect it to be
* - FIX_ME -> refactor that line of code to make the test pass.
*/
describe('this and the global context', () => {
it('can reference the window or global object', () => {
expect(window.color).toBe(/* FILL_ME_IN */);
})
it('can be a bit tricky', () => {
var myVar = 100;
function WhoIsThis() {
this.myVar = 200;
this.display = function() {
var myVar = 300;
return myVar;
};
}
var obj = new WhoIsThis();
expect(obj.display()).toBe(/* FILL_ME_IN */);
});
});
describe('this and method invocation', () => {
var bike = {
brand: 'Specialized',
getBrand: function () {
return this.brand;
}
}
it('refers to an object when used inside the invocation of a method', () => {
expect(bike.getBrand()).toBe(/* FILL_ME_IN */);
})
it('can be bound to a specific object', () => {
var brand = bike.getBrand; // FIX_ME
expect(brand()).toBe('Specialized');
})
it('can invoke a method in the context of another object', () => {
var anotherBike = {
brand: 'Cannondale'
}
var brand = bike.getBrand(anotherBike); // FIX_ME
expect(brand()).toBe('Cannondale');
})
});