Skip to content

Instantly share code, notes, and snippets.

@rightfold
Created April 25, 2014 21:42
Show Gist options
  • Save rightfold/97bfb18a78fac7a0526d to your computer and use it in GitHub Desktop.
Save rightfold/97bfb18a78fac7a0526d to your computer and use it in GitHub Desktop.
{create-project} = require('../../lib/interaction/create-project')
module.exports =
test-name-must-not-be-empty: (t) !->
err, project-id <- create-project({name: ''}, null)
t.deep-equal(err.invalid-fields, [\empty-name])
t.strict-equal(project-id, null)
t.done!
test-must-insert-project: (t) !->
inserted-project = null
inserted-project-id = null
insert-project = (project, callback) !->
inserted-project := project
inserted-project-id := 1
callback(null, inserted-project-id)
err, project-id <- create-project({name: 'foo'}, insert-project)
t.strict-equal(err, null)
t.strict-equal(project-id, inserted-project-id)
t.strict-equal(inserted-project.name, 'foo')
t.done!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment