@@ -8,105 +8,92 @@ describe('Custom Loader', function () {
8
8
it ( 'should support ES6 scripts' , function ( done ) {
9
9
customLoader . import ( 'test/loader/test' )
10
10
. then ( function ( m ) {
11
- setTimeout ( function ( ) {
12
- expect ( m . loader ) . to . be . equal ( 'custom' ) ;
13
- done ( ) ;
14
- } ) ;
15
- } , done )
11
+ expect ( m . loader ) . to . be . equal ( 'custom' ) ;
12
+ } )
13
+ . then ( done , done )
16
14
} ) ;
17
15
18
16
it ( 'should support AMD scripts' , function ( done ) {
19
17
customLoader . import ( 'test/loader/amd' )
20
18
. then ( function ( m ) {
21
- setTimeout ( function ( ) {
22
- expect ( m . format ) . to . be . equal ( 'amd' ) ;
23
- done ( ) ;
24
- } ) ;
25
- } , done )
19
+ expect ( m . format ) . to . be . equal ( 'amd' ) ;
20
+ } )
21
+ . then ( done , done ) ;
26
22
} ) ;
27
23
} ) ;
28
24
29
- describe ( 'special #locate path rule' , function ( ) {
25
+ describe ( 'special #locate path rule' , function a ( ) {
30
26
31
27
it ( 'should support special loading rules' , function ( done ) {
32
28
customLoader . import ( 'path/custom' )
33
29
. then ( function ( m ) {
34
- setTimeout ( function ( ) {
35
- expect ( m . path ) . to . be . ok ( ) ;
36
- done ( ) ;
37
- } ) ;
38
- } , done )
39
- } ) ;
30
+ expect ( m . path ) . to . be . ok ( ) ;
31
+ } )
32
+ . then ( done , done ) ;
33
+ } )
40
34
41
35
} ) ;
42
36
43
37
describe ( 'errors' , function ( ) {
44
38
45
- function dummyLoad ( file , cb ) {
46
- System . import ( file )
47
- . then ( function ( ) {
48
- setTimeout ( function ( ) {
49
- expect ( false , 'should not be successful' ) . to . be . ok ( ) ;
50
- cb ( ) ;
51
- } ) ;
52
- } )
53
- . catch ( function ( e ) {
54
- setTimeout ( function ( ) {
55
- cb ( e ) ;
56
- } ) ;
57
- } )
58
- ;
39
+ function supposeToFail ( ) {
40
+ expect ( false , 'should not be successful' ) . to . be . ok ( ) ;
59
41
}
60
42
61
43
it ( 'should make the normalize throw' , function ( done ) {
62
- dummyLoad ( 'test/loader/error1-parent' , function ( e ) {
63
- expect ( e ) . to . be . match ( / E r r o r l o a d i n g " e r r o r 1 " a t \S + e r r o r 1 \. j s \n E r r o r l o a d i n g " e r r o r 1 " f r o m " t e s t \/ l o a d e r \/ e r r o r 1 - p a r e n t " / ) ;
64
- done ( ) ;
65
- } ) ;
44
+ customLoader . import ( 'test/loader/error1-parent' )
45
+ . then ( supposeToFail , function ( e ) {
46
+ expect ( e ) . to . be . match ( / E r r o r l o a d i n g " t e s t \/ l o a d e r \/ e r r o r 1 - p a r e n t " a t \S + e r r o r 1 - p a r e n t \. j s / ) ;
47
+ } )
48
+ . then ( done , done ) ;
66
49
} ) ;
67
50
68
51
it ( 'should make the locate throw' , function ( done ) {
69
- dummyLoad ( 'test/loader/error2' , function ( e ) {
70
- expect ( e ) . to . be . match ( / E r r o r l o a d i n g " t e s t \/ l o a d e r \/ e r r o r 2 " a t \S + t e s t \/ l o a d e r \/ e r r o r 2 \. j s / ) ;
71
- done ( ) ;
72
- } ) ;
52
+ customLoader . import ( 'test/loader/error2' )
53
+ . then ( supposeToFail , function ( e ) {
54
+ expect ( e ) . to . be . match ( / E r r o r l o a d i n g " t e s t \/ l o a d e r \/ e r r o r 2 " a t \S + t e s t \/ l o a d e r \/ e r r o r 2 \. j s / ) ;
55
+ } )
56
+ . then ( done , done ) ;
73
57
} ) ;
74
58
75
59
it ( 'should make the fetch throw' , function ( done ) {
76
- dummyLoad ( 'test/loader/error3' , function ( e ) {
77
- expect ( e ) . to . be . match ( / E r r o r l o a d i n g " t e s t \/ l o a d e r \/ e r r o r 3 " a t \S + t e s t \/ l o a d e r \/ e r r o r 3 \. j s / ) ;
78
- done ( ) ;
79
- } ) ;
60
+ customLoader . import ( 'test/loader/error3' )
61
+ . then ( supposeToFail , function ( e ) {
62
+ expect ( e ) . to . be . match ( / E r r o r l o a d i n g " t e s t \/ l o a d e r \/ e r r o r 3 " a t \S + t e s t \/ l o a d e r \/ e r r o r 3 \. j s / ) ;
63
+ } )
64
+ . then ( done , done ) ;
80
65
} ) ;
81
66
82
67
it ( 'should make the translate throw' , function ( done ) {
83
- dummyLoad ( 'test/loader/error4' , function ( e ) {
84
- expect ( e ) . to . be . match ( / E r r o r l o a d i n g " t e s t \/ l o a d e r \/ e r r o r 4 " a t \S + t e s t \/ l o a d e r \/ e r r o r 4 \. j s / ) ;
85
- done ( ) ;
86
- } ) ;
68
+ customLoader . import ( 'test/loader/error4' )
69
+ . then ( supposeToFail , function ( e ) {
70
+ expect ( e ) . to . be . match ( / E r r o r l o a d i n g " t e s t \/ l o a d e r \/ e r r o r 4 " a t \S + t e s t \/ l o a d e r \/ e r r o r 4 \. j s / ) ;
71
+ } )
72
+ . then ( done , done ) ;
87
73
} ) ;
88
74
89
75
it ( 'should make the instantiate throw' , function ( done ) {
90
- dummyLoad ( 'test/loader/error5' , function ( e ) {
91
- expect ( e ) . to . be . match ( / E r r o r l o a d i n g " t e s t \/ l o a d e r \/ e r r o r 5 " a t \S + t e s t \/ l o a d e r \/ e r r o r 5 \. j s / ) ;
92
- done ( ) ;
93
- } ) ;
76
+ customLoader . import ( 'test/loader/error5' )
77
+ . then ( supposeToFail , function ( e ) {
78
+ expect ( e ) . to . be . match ( / E r r o r l o a d i n g " t e s t \/ l o a d e r \/ e r r o r 5 " a t \S + t e s t \/ l o a d e r \/ e r r o r 5 \. j s / ) ;
79
+ } )
80
+ . then ( done , done ) ;
94
81
} ) ;
82
+
95
83
} ) ;
96
84
97
85
} ) ;
98
86
99
87
describe ( '#normalize' , function ( ) {
100
88
it ( 'should support async normalization' , function ( done ) {
101
- customLoader . normalize ( 'asdfasdf' ) . then ( function ( normalized ) {
102
- return customLoader . import ( normalized )
103
- } ) . then ( function ( m ) {
104
- setTimeout ( function ( ) {
89
+ customLoader . normalize ( 'asdfasdf' )
90
+ . then ( function ( normalized ) {
91
+ return customLoader . import ( normalized ) ;
92
+ } )
93
+ . then ( function ( m ) {
105
94
expect ( m . n ) . to . be . equal ( 'n' ) ;
106
- done ( ) ;
107
- } ) ;
108
- } )
109
- . catch ( done ) ;
95
+ } )
96
+ . then ( done , done ) ;
110
97
} ) ;
111
98
} ) ;
112
99
} ) ;
0 commit comments