import { assert , expect } from 'chai' ; import { Then } from 'cucumber' ; import { isUndefined } from 'util' ; import { Problem } from '../../lib/domain/entities/Problem' ; let problem ; export function setProblem ( p ) { problem = p ; } function checkProblem ( ) { if ( isUndefined ( problem ) ) { assert . fail ( 'Problem has not been set, forgot to call setProblem?' ) ; } } Then ( 'return Bad Request Problem' , ( ) => { checkProblem ( ) ; expect ( problem . status ) . to . equal ( 400 ) ; } ) ; Then ( 'return Unauthorized Problem' , ( ) => { checkProblem ( ) ; expect ( problem . status ) . to . equal ( 401 ) ; } ) ; Then ( 'return Not Found Problem' , ( ) => { checkProblem ( ) ; expect ( problem . status ) . to . equal ( 404 ) ; } ) ; Then ( 'return Forbidden Problem' , ( ) => { checkProblem ( ) ; expect ( problem . status ) . to . equal ( 403 ) ; } ) ; Then ( 'return Internal Server Error Problem' , ( ) => { checkProblem ( ) ; expect ( problem . status ) . to . equal ( 500 ) ; } ) ; Then ( 'Problem has detail {string}' , ( expectedDetail ) => { checkProblem ( ) ; expect ( problem . detail ) . to . equal ( expectedDetail ) ; } ) ;