-
Notifications
You must be signed in to change notification settings - Fork 784
/
hooks-global-context.js
49 lines (43 loc) 路 1.15 KB
/
hooks-global-context.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
QUnit.hooks.beforeEach( function() {
this.x = 1;
this.fromGlobal = true;
} );
QUnit.hooks.afterEach( function() {
this.x = 100;
} );
QUnit.module( "A", function( hooks ) {
hooks.beforeEach( function() {
this.x = 2;
this.fromModule = true;
} );
hooks.afterEach( function() {
this.x = 20;
} );
QUnit.test( "A1", function( assert ) {
assert.equal( this.x, 2 );
assert.strictEqual( this.fromGlobal, true );
assert.strictEqual( this.fromModule, true );
assert.strictEqual( this.fromNested, undefined );
} );
QUnit.module( "AB", function( hooks ) {
hooks.beforeEach( function() {
this.x = 3;
this.fromNested = true;
} );
hooks.afterEach( function() {
this.x = 30;
} );
QUnit.test( "AB1", function( assert ) {
assert.strictEqual( this.x, 3 );
assert.strictEqual( this.fromGlobal, true );
assert.strictEqual( this.fromModule, true );
assert.strictEqual( this.fromNested, true );
} );
} );
} );
QUnit.test( "B", function( assert ) {
assert.strictEqual( this.x, 1 );
assert.strictEqual( this.fromGlobal, true );
assert.strictEqual( this.fromModule, undefined );
assert.strictEqual( this.fromNested, undefined );
} );