File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ export class Response {
7676 constructor ( responseOptions : ResponseOptions ) {
7777 this . _body = responseOptions . body ;
7878 this . status = responseOptions . status ;
79+ this . ok = ( this . status >= 200 && this . status <= 299 ) ;
7980 this . statusText = responseOptions . statusText ;
8081 this . headers = responseOptions . headers ;
8182 this . type = responseOptions . type ;
Original file line number Diff line number Diff line change 1+ import {
2+ describe ,
3+ expect ,
4+ it ,
5+ } from 'angular2/testing_internal' ;
6+
7+ import { ResponseOptions } from 'angular2/src/http/base_response_options' ;
8+ import { Response } from 'angular2/src/http/static_response' ;
9+
10+
11+
12+ export function main ( ) {
13+ describe ( 'Response' , ( ) => {
14+ it ( 'should be ok for 200 statuses' , ( ) => {
15+ expect ( new Response ( new ResponseOptions ( { status : 200 } ) ) . ok ) . toEqual ( true ) ;
16+ expect ( new Response ( new ResponseOptions ( { status : 299 } ) ) . ok ) . toEqual ( true ) ;
17+ } ) ;
18+
19+ it ( 'should not be ok for non 200 statuses' , ( ) => {
20+ expect ( new Response ( new ResponseOptions ( { status : 199 } ) ) . ok ) . toEqual ( false ) ;
21+ expect ( new Response ( new ResponseOptions ( { status : 300 } ) ) . ok ) . toEqual ( false ) ;
22+ } ) ;
23+ } ) ;
24+ }
You can’t perform that action at this time.
0 commit comments