Created
March 7, 2014 10:26
-
-
Save misablaha/9409100 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('cson-config').load() | |
brokerClient = require 'broker-client' | |
config = process.config | |
app = brokerClient config.broker | |
# middleware | |
app.use (req, res, next)-> | |
console.log "#{req.method} #{req.path} from #{req.headers['x-forwarded-for']}" | |
next() | |
app.listen config.port, ()-> | |
console.log "listen #{config.port}" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe 'workshop api', -> | |
@timeout 5000 | |
get '/0/workshop', (req, body, done)-> | |
assert.equal body.data.working, yes, "Bad response, working isn't yes" | |
done() | |
input= | |
data: | |
test: yes | |
post '/0/workshop/params', input, (req, body, done)-> | |
assert.equal JSON.stringify(input.data), JSON.stringify(body.data), "Something went wrong :/" | |
done() | |
data= | |
data: | |
counter: 10 | |
headers: | |
token: 'token' | |
post '/0/workshop/post', {data: data.data}, (req, body, done)-> | |
assert.equal body.error.message, "bad token", "Expected error response!" | |
done() | |
post '/0/workshop/post', data, (req, body, done)-> | |
assert.equal body.data.result, 5, "Bad result" | |
done() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment