@@ -97,6 +97,43 @@ describe('basic usage', function() {
97
97
$httpBackend . flush ( ) ;
98
98
} ) ;
99
99
100
+ it ( 'should include a request body when calling custom delete with hasBody is true' , function ( ) {
101
+ var condition = { at : "2038-01-19 03:14:08" }
102
+ $httpBackend . expect ( 'DELETE' , '/fooresource' , condition ) . respond ( { } ) ;
103
+
104
+ var r = $resource ( '/fooresource' , { } , {
105
+ delete : { method : 'DELETE' , hasBody : true }
106
+ } ) ;
107
+
108
+ var deleteResponse = r . delete ( condition ) ;
109
+
110
+ $httpBackend . flush ( ) ;
111
+
112
+ expect ( deleteResponse . $resolved ) . toBe ( true ) ;
113
+ } ) ;
114
+
115
+ it ( 'should expect a body if hasBody is true' , function ( ) {
116
+ var username = "yathos" ;
117
+ var loginRequest = { name : username , password : "Smile" } ;
118
+ var user = { id : 1 , name : username } ;
119
+
120
+ $httpBackend . expect ( 'LOGIN' , '/user/me' , loginRequest ) . respond ( user ) ;
121
+
122
+ $httpBackend . expect ( 'LOGOUT' , '/user/me' , null ) . respond ( null ) ;
123
+
124
+ var UserService = $resource ( '/user/me' , { } , {
125
+ login : { method : 'LOGIN' , hasBody : true } ,
126
+ logout : { method : 'LOGOUT' , hasBody : false }
127
+ } ) ;
128
+
129
+ var loginResponse = UserService . login ( loginRequest ) ;
130
+ var logoutResponse = UserService . logout ( ) ;
131
+
132
+ $httpBackend . flush ( ) ;
133
+
134
+ expect ( loginResponse . id ) . toBe ( user . id ) ;
135
+ expect ( logoutResponse . $resolved ) . toBe ( true ) ;
136
+ } ) ;
100
137
101
138
it ( 'should build resource' , function ( ) {
102
139
expect ( typeof CreditCard ) . toBe ( 'function' ) ;
0 commit comments