Skip to content
Myr

spec.async.js

This file

Path

spec/spec.async.js

32 lines · 843 bytes · JavaScript

Last changed by

Fixed whitespace from another devs commitsvisionmediabefore adoptionf623873

History of this file

Take it

Asynchronous handlers working.csausdevbefore adoptiona3ca40e

lines 1–7why, one step back
1
2describe 'Express'3 describe 'server'4 before_each5 Express.routes = []6 end7

Fixed whitespace from another devs commitsvisionmediabefore adoptionf623873

lines 8–29why, one step back
8 describe 'callback'
9 it 'should wait for an asynchronous handler to finish'10 require('jspec.timers')11 get('pants', function() {12 setTimeout(function() {13 Express.server.finished('asynchronous thing done')14 }, 50)15 })16 var response = get('pants')17 response.body.should.be_null18 19 tick(50)20 response.body.should.eql 'asynchronous thing done'21 response.status.should.eql 20022 response.headers['content-type'].should.eql 'text/html'23 end24 25 it 'should still accept a synchronous handler that returns a string'26 get('pants', function() { 'no pants' })27 get('pants').body.should.eql 'no pants'28 end29 end

Asynchronous handlers working.csausdevbefore adoptiona3ca40e

lines 30–32why, one step back
30 end
31end32