@@ -1020,6 +1020,61 @@ describe('$http', function() {
1020
1020
} ) ;
1021
1021
1022
1022
1023
+ it ( 'should deserialize json numbers when response header contains application/json' ,
1024
+ function ( ) {
1025
+ $httpBackend . expect ( 'GET' , '/url' ) . respond ( '123' , { 'Content-Type' : 'application/json' } ) ;
1026
+ $http ( { method : 'GET' , url : '/url' } ) . success ( callback ) ;
1027
+ $httpBackend . flush ( ) ;
1028
+
1029
+ expect ( callback ) . toHaveBeenCalledOnce ( ) ;
1030
+ expect ( callback . mostRecentCall . args [ 0 ] ) . toEqual ( 123 ) ;
1031
+ } ) ;
1032
+
1033
+
1034
+ it ( 'should deserialize json strings when response header contains application/json' ,
1035
+ function ( ) {
1036
+ $httpBackend . expect ( 'GET' , '/url' ) . respond ( '"asdf"' , { 'Content-Type' : 'application/json' } ) ;
1037
+ $http ( { method : 'GET' , url : '/url' } ) . success ( callback ) ;
1038
+ $httpBackend . flush ( ) ;
1039
+
1040
+ expect ( callback ) . toHaveBeenCalledOnce ( ) ;
1041
+ expect ( callback . mostRecentCall . args [ 0 ] ) . toEqual ( 'asdf' ) ;
1042
+ } ) ;
1043
+
1044
+
1045
+ it ( 'should deserialize json nulls when response header contains application/json' ,
1046
+ function ( ) {
1047
+ $httpBackend . expect ( 'GET' , '/url' ) . respond ( 'null' , { 'Content-Type' : 'application/json' } ) ;
1048
+ $http ( { method : 'GET' , url : '/url' } ) . success ( callback ) ;
1049
+ $httpBackend . flush ( ) ;
1050
+
1051
+ expect ( callback ) . toHaveBeenCalledOnce ( ) ;
1052
+ expect ( callback . mostRecentCall . args [ 0 ] ) . toEqual ( null ) ;
1053
+ } ) ;
1054
+
1055
+
1056
+ it ( 'should deserialize json true when response header contains application/json' ,
1057
+ function ( ) {
1058
+ $httpBackend . expect ( 'GET' , '/url' ) . respond ( 'true' , { 'Content-Type' : 'application/json' } ) ;
1059
+ $http ( { method : 'GET' , url : '/url' } ) . success ( callback ) ;
1060
+ $httpBackend . flush ( ) ;
1061
+
1062
+ expect ( callback ) . toHaveBeenCalledOnce ( ) ;
1063
+ expect ( callback . mostRecentCall . args [ 0 ] ) . toEqual ( true ) ;
1064
+ } ) ;
1065
+
1066
+
1067
+ it ( 'should deserialize json false when response header contains application/json' ,
1068
+ function ( ) {
1069
+ $httpBackend . expect ( 'GET' , '/url' ) . respond ( 'false' , { 'Content-Type' : 'application/json' } ) ;
1070
+ $http ( { method : 'GET' , url : '/url' } ) . success ( callback ) ;
1071
+ $httpBackend . flush ( ) ;
1072
+
1073
+ expect ( callback ) . toHaveBeenCalledOnce ( ) ;
1074
+ expect ( callback . mostRecentCall . args [ 0 ] ) . toEqual ( false ) ;
1075
+ } ) ;
1076
+
1077
+
1023
1078
it ( 'should deserialize json with security prefix' , function ( ) {
1024
1079
$httpBackend . expect ( 'GET' , '/url' ) . respond ( ')]}\',\n[1, "abc", {"foo":"bar"}]' ) ;
1025
1080
$http ( { method : 'GET' , url : '/url' } ) . success ( callback ) ;
0 commit comments