File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ export class Response {
76
76
constructor ( responseOptions : ResponseOptions ) {
77
77
this . _body = responseOptions . body ;
78
78
this . status = responseOptions . status ;
79
+ this . ok = ( this . status >= 200 && this . status <= 299 ) ;
79
80
this . statusText = responseOptions . statusText ;
80
81
this . headers = responseOptions . headers ;
81
82
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