login.test.js 1021 字节
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 中填写账号密码!!!')
L
Lunan Li 已提交
6 7 8
const country_code = '1'
const phone = '3156678705'
const password = '1q2w3e4R'
B
binaryify 已提交
9
describe('测试登录是否正常', () => {
B
binaryify 已提交
10
  it('手机登录 code 应该等于200', (done) => {
N
Nzix 已提交
11
    const qs = {
L
Lunan Li 已提交
12 13
      countrycode:
        process.env.NCM_API_TEST_LOGIN_COUNTRY_CODE || country_code || '',
B
binaryify 已提交
14 15
      phone: process.env.NCM_API_TEST_LOGIN_PHONE || phone || '',
      password: process.env.NCM_API_TEST_LOGIN_PASSWORD || password || '',
N
Nzix 已提交
16
    }
17

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