From 17c248e9709503b220440ee920ec13308bb1f57c Mon Sep 17 00:00:00 2001 From: Blade Barringer Date: Thu, 7 May 2015 21:33:59 -0500 Subject: [PATCH] Add readme. Adjust api-helper.coffee --- test/api/README.md | 20 ++++++++++++++++++++ test/api/api-helper.coffee | 3 +-- 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 test/api/README.md diff --git a/test/api/README.md b/test/api/README.md new file mode 100644 index 0000000000..4965dd79d3 --- /dev/null +++ b/test/api/README.md @@ -0,0 +1,20 @@ +# API Tests + +Our API tests are written in [coffeescript](http://coffeescript.org/) using the [Mocha testing framework](http://mochajs.org/). + +### Modules +Some modules are declared in the [api-helper.coffee](api-helper.coffee) file for use in any of the api tests: + +* `moment` - time manipulation +* `async` - run async processes, good for before blocks +* `lodash (_)` - many utilities +* `shared` - generate uuids +* `expect` - making assertions +* `User` - look up a User in the db + +## Helper Methods + +There are helper methods declared in the [api-helper.coffee](api-helper.coffee) file. Some useful methods contained there: + +* `registerNewUser(callback, main)` - Theres a global user variable that gets overwritten with the new user whenever you call `registerNewUser` unless you pass false in as the second argument. +* `registerManyUsers(number, callback)` - Good for testing things that require many users. The callback function returns new users as and array in the second argument. diff --git a/test/api/api-helper.coffee b/test/api/api-helper.coffee index 6aac442d88..67e48f0fc0 100644 --- a/test/api/api-helper.coffee +++ b/test/api/api-helper.coffee @@ -1,4 +1,3 @@ -global.User = require("../../website/src/models/user").model ############################## # Global modules ############################## @@ -10,6 +9,7 @@ global.async = require("async") global._ = require("lodash") global.expect = require("expect.js") global.shared = require("../../common") +global.User = require("../../website/src/models/user").model ############################## # Nconf config @@ -34,7 +34,6 @@ global.expectCode = (res, code) -> global.expect(res.body.err).to.be `undefined` if code is 200 global.expect(res.statusCode).to.be code - global.registerNewUser = (cb, main) -> main = true unless main? randomID = shared.uuid()