File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed
Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change 1- function isOk ( status ) {
2- return status === 200 ;
1+ import validateHttpStatus from './utils/validate-http-status' ;
2+
3+ /**
4+ * Validate HTTP Status code 200 type SUCCESS
5+ *
6+ * @param {integer } statusCode - The HTTP Status code
7+ * @throws {HTTPStatusError } Will throw an error if the @param {statusCode} is different then 200
8+ * @return {boolean }
9+ */
10+ function isOk ( statusCode ) {
11+ return validateHttpStatus ( statusCode , 200 ) ;
312}
413
514export default isOk ;
Original file line number Diff line number Diff line change 11import { isOk } from '../src' ;
22
33describe ( 'isOk' , ( ) => {
4- test ( 'it should test isOk status equal 200' , ( ) => {
4+ test ( 'it should receive true when pass status 200' , ( ) => {
55 expect ( isOk ( 200 ) ) . toBeTruthy ( ) ;
66 } ) ;
77
8- test ( 'it should test isOk status different then 201' , ( ) => {
9- expect ( isOk ( 201 ) ) . toBeFalsy ( ) ;
8+ test ( 'it should throw Error when pass status different than 200' , ( ) => {
9+ const received = isOk ( 300 ) ;
10+ expect ( received . message ) . toBe ( 'Expected a 200 response.' ) ;
1011 } ) ;
1112} ) ;
You can’t perform that action at this time.
0 commit comments