forked from thinkb4/a-walk-in-javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhoisting.test.js
37 lines (26 loc) · 1.05 KB
/
hoisting.test.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
describe('DAY 6: Test Hoisting', () => {
it(`myHoistedVariable should be hoisted as undefined,
NOT to throw a reference error`, () => {
expect(myHoistedVariable).toBeUndefined();
// change the declaration statement to complete the test
let myHoistedVariable = 3;
});
it(`myHoistedFunctionExpression should be hoisted as undefined,
NOT to throw a reference error`, () => {
expect(myHoistedFunctionExpression).toBeUndefined();
// change the declaration statement to complete the test
const myHoistedFunctionExpression = function () {
};
});
it(`myHoistedFunctionDeclaration should be hoisted together with its body,
NOT to throw a reference error`, () => {
// change the expect clause to complete the test
// @see https://jestjs.io/docs/en/expect documentation for help
expect(myHoistedFunctionDeclaration).toThrow();
/**
* @returns {undefined}
*/
function myHoistedFunctionDeclaration () {
}
});
});