Skip to content

Instantly share code, notes, and snippets.

@ksato9700
Created September 16, 2012 03:16
Show Gist options
  • Save ksato9700/3730889 to your computer and use it in GitHub Desktop.
Save ksato9700/3730889 to your computer and use it in GitHub Desktop.
mocha iterative test case example
class Client
constructor: (name, ready)->
setTimeout =>
@name = name
ready()
, 1000
exports.Client = Client
async = require 'async'
assert = require 'assert'
client = require '../client'
NAMES = [
"jp00_basic",
"us00_basic",
"gb00_basic",
]
cps = {}
gencheck = (name)->
->
assert.equal cps[name].name, name
describe 'User', ->
before (done)->
async.forEach NAMES, (name, cb)->
cps[name] = new client.Client name, cb
, (err)->
assert.equal err, null
done()
for name in NAMES
it "should have a name (#{name})", gencheck(name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment