File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,24 @@ describe("server", () => {
8383 const result = spy . calledWith ( "GET /json - ::ffff:127.0.0.1" ) ;
8484 assert . ok ( result ) ;
8585 } ) ;
86+ // 8.1
87+ it ( 'should return json `{ time: timestamp }` from the "/now" endpoint' , ( ) => {
88+ return request ( server )
89+ . get ( "/now" )
90+ . expect ( "Content-type" , / a p p l i c a t i o n \/ j s o n / )
91+ . expect ( 200 )
92+ . then ( response => {
93+ assert . ok ( response . body , "Body does not contain json" ) ;
94+ // TODO: validate uses middleware
95+ const now = + new Date ( ) ;
96+ const sendTime = + new Date ( response . body . time ) ;
97+ const withinRange = now - sendTime < 3000 ;
98+ assert . ok (
99+ withinRange ,
100+ `Timestamp ${ response . body . time } is not within range of 3 seconds`
101+ ) ;
102+ } ) ;
103+ } ) ;
86104 after ( ( ) => {
87105 server . close ( ) ;
88106 } ) ;
You can’t perform that action at this time.
0 commit comments