search.test.js 640 B

12345678910111213141516171819202122232425
  1. const assert = require('assert')
  2. const { default: axios } = require('axios')
  3. const host = global.host || 'http://localhost:3000'
  4. describe('测试搜索是否正常', () => {
  5. it('获取到的数据的 name 应该和搜索关键词一致', (done) => {
  6. const qs = {
  7. keywords: '海阔天空',
  8. type: 1,
  9. realIP: global.cnIp,
  10. }
  11. axios
  12. .get(`${host}/search`, {
  13. params: qs,
  14. })
  15. .then(({ status, data }) => {
  16. if (status == 200) {
  17. assert(data.result.songs[0].name === '海阔天空')
  18. }
  19. done()
  20. })
  21. .catch((err) => {
  22. done(err)
  23. })
  24. })
  25. })