@@ -151,6 +151,19 @@ export function main() {
151151 . subscribe ( ( res ) => { } ) ;
152152 } ) ) ;
153153
154+ it ( 'should accept a fully-qualified request as its only parameter' ,
155+ inject ( [ AsyncTestCompleter ] , ( async ) => {
156+ backend . connections . subscribe ( c => {
157+ expect ( c . request . url ) . toBe ( 'https://google.com' ) ;
158+ expect ( c . request . method ) . toBe ( RequestMethods . Post ) ;
159+ c . mockRespond ( new Response ( new ResponseOptions ( { body : 'Thank you' } ) ) ) ;
160+ async . done ( ) ;
161+ } ) ;
162+ http . request ( new Request ( new RequestOptions (
163+ { url : 'https://google.com' , method : RequestMethods . Post } ) ) )
164+ . subscribe ( ( res ) => { } ) ;
165+ } ) ) ;
166+
154167
155168 it ( 'should perform a get request for given url if only passed a string' ,
156169 inject ( [ AsyncTestCompleter ] , ( async ) => {
@@ -162,6 +175,34 @@ export function main() {
162175 } ) ;
163176 } ) ) ;
164177
178+ it ( 'should perform a post request for given url if options include a method' ,
179+ inject ( [ AsyncTestCompleter ] , ( async ) => {
180+ backend . connections . subscribe ( c => {
181+ expect ( c . request . method ) . toEqual ( RequestMethods . Post ) ;
182+ c . mockRespond ( baseResponse ) ;
183+ } ) ;
184+ let requestOptions = new RequestOptions ( { method : RequestMethods . Post } ) ;
185+ http . request ( 'http://basic.connection' , requestOptions )
186+ . subscribe ( res => {
187+ expect ( res . text ( ) ) . toBe ( 'base response' ) ;
188+ async . done ( ) ;
189+ } ) ;
190+ } ) ) ;
191+
192+ it ( 'should perform a post request for given url if options include a method' ,
193+ inject ( [ AsyncTestCompleter ] , ( async ) => {
194+ backend . connections . subscribe ( c => {
195+ expect ( c . request . method ) . toEqual ( RequestMethods . Post ) ;
196+ c . mockRespond ( baseResponse ) ;
197+ } ) ;
198+ let requestOptions = { method : RequestMethods . Post } ;
199+ http . request ( 'http://basic.connection' , requestOptions )
200+ . subscribe ( res => {
201+ expect ( res . text ( ) ) . toBe ( 'base response' ) ;
202+ async . done ( ) ;
203+ } ) ;
204+ } ) ) ;
205+
165206 it ( 'should perform a get request and complete the response' ,
166207 inject ( [ AsyncTestCompleter ] , ( async ) => {
167208 backend . connections . subscribe ( c => c . mockRespond ( baseResponse ) ) ;
@@ -180,18 +221,6 @@ export function main() {
180221 . subscribe ( res => { expect ( res . text ( ) ) . toBe ( 'base response' ) ; } , null ,
181222 ( ) => { async . done ( ) ; } ) ;
182223 } ) ) ;
183- // TODO: make dart not complain about "argument type 'Map' cannot be assigned to the
184- // parameter type 'IRequestOptions'"
185- // xit('should perform a get request for given url if passed a dictionary',
186- // inject([AsyncTestCompleter], async => {
187- // ObservableWrapper.subscribe(backend.connections, c => c.mockRespond(baseResponse));
188- // ObservableWrapper.subscribe(http.request(url, {method: RequestMethods.GET}), res =>
189- // {
190- // expect(res.text()).toBe('base response');
191- // async.done();
192- // });
193- // }));
194-
195224
196225 it ( 'should throw if url is not a string or Request' , ( ) => {
197226 var req = < Request > { } ;
0 commit comments