1234567891011121314151617181920212223242526 |
- import mongoose from 'mongoose'
- export function cleanDb() {
- for (const collection in mongoose.connection.collections) {
- if (mongoose.connection.collections.hasOwnProperty(collection)) {
- mongoose.connection.collections[collection].remove()
- }
- }
- }
- export function authUser(agent, callback) {
- agent
- .post('/users')
- .set('Accept', 'application/json')
- .send({ user: { username: 'test', password: 'pass' } })
- .end((err, res) => {
- if (err) {
- return callback(err)
- }
- callback(null, {
- user : res.body.user,
- token: res.body.token
- })
- })
- }
|