@@ -25,27 +25,45 @@ describe('AppConfigPlugin', function() {
2525
2626 Utils . setFuncName ( route , 'route:index' ) ;
2727
28- const config = { foo : 'bar' } ;
28+ describe ( 'loaded' , function ( ) {
29+ const config = { foo : 'bar' } ;
2930
30- stack . middleware = [ middleware ( config ) ] ;
31- stack . routes = route ;
31+ stack . middleware = [ middleware ( config ) ] ;
32+ stack . routes = route ;
3233
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 ( { } ) ;
3536
36- stack . exec ( req , res ) ;
37+ stack . exec ( req , res ) ;
3738
38- const result = res . data ( ) ;
39+ const result = res . data ( ) ;
3940
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+ } ) ;
4348
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+ } ) ;
4652 } ) ;
4753
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+ } ) ;
5068 } ) ;
5169} ) ;
0 commit comments