@@ -25,27 +25,45 @@ describe('AppConfigPlugin', function() {
25
25
26
26
Utils . setFuncName ( route , 'route:index' ) ;
27
27
28
- const config = { foo : 'bar' } ;
28
+ describe ( 'loaded' , function ( ) {
29
+ const config = { foo : 'bar' } ;
29
30
30
- stack . middleware = [ middleware ( config ) ] ;
31
- stack . routes = route ;
31
+ stack . middleware = [ middleware ( config ) ] ;
32
+ stack . routes = route ;
32
33
33
- const req = new Request ( event . Records [ 0 ] . cf . request , { } ) ;
34
- const res = new Response ( { } ) ;
34
+ const req = new Request ( event . Records [ 0 ] . cf . request , { } ) ;
35
+ const res = new Response ( { } ) ;
35
36
36
- stack . exec ( req , res ) ;
37
+ stack . exec ( req , res ) ;
37
38
38
- const result = res . data ( ) ;
39
+ const result = res . data ( ) ;
39
40
40
- it ( 'should not return headers' , function ( ) {
41
- expect ( result . headers ) . to . be . empty ;
42
- } ) ;
41
+ it ( 'should not return headers' , function ( ) {
42
+ expect ( result . headers ) . to . be . empty ;
43
+ } ) ;
44
+
45
+ it ( 'should return status' , function ( ) {
46
+ expect ( result . status ) . to . equal ( 200 ) ;
47
+ } ) ;
43
48
44
- it ( 'should return status' , function ( ) {
45
- expect ( result . status ) . to . equal ( 200 ) ;
49
+ it ( 'should return body' , function ( ) {
50
+ expect ( result . body ) . to . equal ( 'bar' ) ;
51
+ } ) ;
46
52
} ) ;
47
53
48
- it ( 'should return body' , function ( ) {
49
- expect ( result . body ) . to . equal ( 'bar' ) ;
54
+ describe ( 'error' , function ( ) {
55
+ const config = null ;
56
+
57
+ stack . middleware = [ middleware ( config ) ] ;
58
+ stack . routes = route ;
59
+
60
+ const req = new Request ( event . Records [ 0 ] . cf . request , { } ) ;
61
+ const res = new Response ( { } ) ;
62
+
63
+ const result = ( ) => stack . exec ( req , res ) ;
64
+
65
+ it ( 'should throw Error' , function ( ) {
66
+ expect ( result ) . to . throw ( Error , / M i s s i n g c o n f i g u r a t i o n / ) ;
67
+ } ) ;
50
68
} ) ;
51
69
} ) ;
0 commit comments