login.test.js 640 字节
Newer Older
N
Nzix 已提交
1 2
const assert = require('assert')
const request = require('request')
N
Nzix 已提交
3
const host = global.host || 'http://localhost:3000'
4

B
binaryify 已提交
5
console.log('注意: 测试登录需在 test/login.test.js 中填写账号密码!!!');
6

B
binaryify 已提交
7 8
describe('测试登录是否正常', () => {
  it('手机登录 code 应该等于200', done => {
N
Nzix 已提交
9
    const qs = {
B
binaryify 已提交
10
      phone: phone,
N
Nzix 已提交
11 12
      password: password
    }
13

B
binaryify 已提交
14
    request.get({url: `${host}/login/cellphone`, qs: qs}, (err, res, body) => {
N
Nzix 已提交
15 16 17 18 19 20 21 22 23 24 25
      if (!err && res.statusCode == 200) {
        body = JSON.parse(body)
        assert(body.code === 200)
        done()
      }
      else{
        done(err)
      }
    })
  })
})