mirror of
https://github.com/HackPlan/RootPanel.git
synced 2026-04-23 03:10:30 +08:00
refactor with promise
This commit is contained in:
@@ -5,13 +5,13 @@ global._ = require 'underscore'
|
||||
global.fs = require 'fs'
|
||||
|
||||
if fs.existsSync "#{__dirname}/../config.coffee"
|
||||
config = require '../config'
|
||||
global.config = require '../config'
|
||||
else
|
||||
config = require '../sample/core.config.coffee'
|
||||
global.config = require '../sample/core.config.coffee'
|
||||
|
||||
global.Q = require 'q'
|
||||
global.chai = require 'chai'
|
||||
global.async = require 'async'
|
||||
global.config = config
|
||||
global.supertest = require 'supertest'
|
||||
|
||||
if process.env.COV_TEST == 'true'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
utils = require '../core/utils'
|
||||
global.utils = require '../core/utils'
|
||||
|
||||
createAgent = (callback) ->
|
||||
agent = supertest.agent app.express
|
||||
@@ -9,6 +9,9 @@ createAgent = (callback) ->
|
||||
agent: agent
|
||||
csrf_token: res.body.csrf_token
|
||||
|
||||
cleanUpByAccount = ({account_id}, callback) ->
|
||||
app.models.Account.findByIdAndRemove account_id, callback
|
||||
|
||||
createLoggedAgent = (callback) ->
|
||||
createAgent (err, {agent, csrf_token}) ->
|
||||
username = 'test' + utils.randomString(8).toLowerCase()
|
||||
@@ -22,6 +25,9 @@ createLoggedAgent = (callback) ->
|
||||
email: email
|
||||
password: password
|
||||
.end (err, res) ->
|
||||
after (done) ->
|
||||
cleanUpByAccount res.body.account_id, done
|
||||
|
||||
callback err,
|
||||
agent: agent
|
||||
username: username
|
||||
@@ -32,4 +38,5 @@ createLoggedAgent = (callback) ->
|
||||
|
||||
_.extend global,
|
||||
createAgent: createAgent
|
||||
cleanUpByAccount: cleanUpByAccount
|
||||
createLoggedAgent: createLoggedAgent
|
||||
|
||||
Reference in New Issue
Block a user