@@ -65,7 +65,7 @@ describe("FastBoot", function() {
6565 } ) ;
6666 } ) ;
6767
68- it ( "renders an empty page if the resilient flag is set" , function ( ) {
68+ it ( "renders no FastBoot markup if the resilient flag is set" , function ( ) {
6969 let middleware = fastbootMiddleware ( {
7070 distPath : fixture ( 'rejected-promise' ) ,
7171 resilient : true
@@ -79,6 +79,54 @@ describe("FastBoot", function() {
7979 } ) ;
8080 } ) ;
8181
82+ it ( "propagates to error handling middleware if the resilient flag is set" , function ( ) {
83+ let middleware = fastbootMiddleware ( {
84+ distPath : fixture ( 'rejected-promise' ) ,
85+ resilient : true
86+ } ) ;
87+ server = new TestHTTPServer ( middleware , { errorHandling : true } ) ;
88+
89+ return server . start ( )
90+ . then ( ( ) => server . request ( '/' , { resolveWithFullResponse : true } ) )
91+ . then ( ( { body, statusCode, headers } ) => {
92+ expect ( statusCode ) . to . equal ( 200 ) ;
93+ expect ( headers [ 'x-test-error' ] ) . to . match ( / e r r o r h a n d l e r c a l l e d / ) ;
94+ expect ( body ) . to . match ( / h e l l o w o r l d / ) ;
95+ } ) ;
96+ } ) ;
97+
98+ it ( "propagates to error handling middleware if the resilient flag is not set" , function ( ) {
99+ let middleware = fastbootMiddleware ( {
100+ distPath : fixture ( 'rejected-promise' ) ,
101+ resilient : false ,
102+ } ) ;
103+ server = new TestHTTPServer ( middleware , { errorHandling : true } ) ;
104+
105+ return server . start ( )
106+ . then ( ( ) => server . request ( '/' , { resolveWithFullResponse : true } ) )
107+ . catch ( ( { statusCode, response : { headers } } ) => {
108+ expect ( statusCode ) . to . equal ( 500 ) ;
109+ expect ( headers [ 'x-test-error' ] ) . to . match ( / e r r o r h a n d l e r c a l l e d / ) ;
110+ } ) ;
111+ } ) ;
112+
113+ it ( "is does not propagate errors when the reslient flag is set and there is no error handling middleware" , function ( ) {
114+ let middleware = fastbootMiddleware ( {
115+ distPath : fixture ( 'rejected-promise' ) ,
116+ resilient : true ,
117+ } ) ;
118+ server = new TestHTTPServer ( middleware , { errorHandling : false } ) ;
119+
120+ return server . start ( )
121+ . then ( ( ) => server . request ( '/' , { resolveWithFullResponse : true } ) )
122+ . then ( ( { body, statusCode, headers } ) => {
123+ expect ( statusCode ) . to . equal ( 200 ) ;
124+ expect ( headers [ 'x-test-error' ] ) . to . not . match ( / e r r o r h a n d l e r c a l l e d / ) ;
125+ expect ( body ) . to . not . match ( / e r r o r / ) ;
126+ expect ( body ) . to . match ( / h e l l o w o r l d / ) ;
127+ } ) ;
128+ } ) ;
129+
82130 it ( "can be provided with a custom FastBoot instance" , function ( ) {
83131 let fastboot = new FastBoot ( {
84132 distPath : fixture ( 'basic-app' )
0 commit comments