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

B
binaryify 已提交
5
console.log('注意: 测试登录需在 test/login.test.js 中填写账号密码!!!')
6 7
const phone = ''
const password = ''
B
binaryify 已提交
8
describe('测试登录是否正常', () => {
B
binaryify 已提交
9
  it('手机登录 code 应该等于200', (done) => {
N
Nzix 已提交
10
    const qs = {
B
binaryify 已提交
11 12
      phone: process.env.NCM_API_TEST_LOGIN_PHONE || phone || '',
      password: process.env.NCM_API_TEST_LOGIN_PASSWORD || password || '',
N
Nzix 已提交
13
    }
14

YXL76's avatar
YXL76 已提交
15 16 17 18 19 20 21 22
    axios
      .get(`${host}/login/cellphone`, {
        params: qs,
      })
      .then(({ status, data }) => {
        if (status == 200) {
          console.log('昵称:' + data.profile.nickname)
          assert(data.code === 200)
B
binaryify 已提交
23
          done()
YXL76's avatar
YXL76 已提交
24 25
        } else {
          done('登录错误')
B
binaryify 已提交
26
        }
YXL76's avatar
YXL76 已提交
27 28 29 30
      })
      .catch((err) => {
        done(err)
      })
N
Nzix 已提交
31 32
  })
})