@@ -55,6 +55,15 @@ describe('Response', () => {
5555 expect ( response . data ) . toBeNull ( ) ;
5656 } ) ;
5757
58+ it ( 'should not parse if status code is 204' , ( ) => {
59+ response . contentType = 'plain/text' ;
60+ response . statusCode = 204 ;
61+ response . parse ( ) ;
62+ expect ( response . parsed ) . toBeFalsy ( ) ;
63+ expect ( response . result ) . toBeNull ( ) ;
64+ expect ( response . data ) . toBeNull ( ) ;
65+ } ) ;
66+
5867 it ( 'should handle badly formed json' , ( ) => {
5968 response . addChunk ( '{ "a" : ' ) ;
6069 response . parse ( ) ;
@@ -65,6 +74,12 @@ describe('Response', () => {
6574 } ) ;
6675
6776 describe ( '.success' , ( ) => {
77+ it ( 'be true if the document was not parsed with a 204 status code' , ( ) => {
78+ response . statusCode = 204 ;
79+ response . parsed = false ;
80+ expect ( response . success ( ) ) . toBeTruthy ( ) ;
81+ } ) ;
82+
6883 it ( 'be true if the document was parsed and with a 2XX status code' , ( ) => {
6984 response . statusCode = 201 ;
7085 response . parsed = true ;
@@ -77,7 +92,7 @@ describe('Response', () => {
7792 expect ( response . success ( ) ) . toBeFalsy ( ) ;
7893 } ) ;
7994
80- it ( 'be false if the document was not parsed and with a 2XX status code' , ( ) => {
95+ it ( 'be false if the document was not parsed and with a 2XX status code excluding 204 ' , ( ) => {
8196 response . statusCode = 201 ;
8297 response . parsed = false ;
8398 expect ( response . success ( ) ) . toBeFalsy ( ) ;
0 commit comments