Union of hero bots.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

52 lines
1.3 KiB

/**
* HeroUnion测试用例
* 执行此测试之前,请先启动主程序,在根目录执行命令:npm start
*/
import test from 'node:test';
import assert from 'node:assert';
import axios from 'axios';
import common from '../common.mjs';
import HeroUnion from '../heroUnion.mjs';
const axiosConfig = {
timeout: 5000,
proxy: false
};
test('HeroUnion api list test', async (t) => {
let api = 'http://127.0.0.1:8080/api/';
const response = await axios.get(api, axiosConfig);
console.log(response.data);
assert.equal(response.status, 200);
});
test('Hero onboard test', async (t) => {
let params = {
name: 'test_hero',
description: 'Hero test 测试爬虫',
status: 'idle',
timestamp: common.getTimestampInSeconds(),
country: 'cn',
lang: 'zh'
};
let api = 'http://127.0.0.1:8080/api/onboard/';
const response = await axios.post(api, params, axiosConfig);
console.log(response.data);
assert.equal(response.status, 200);
assert.equal(response.data.code, 1);
});
test('HeroUnion stats test', async (t) => {
let api = 'http://127.0.0.1:8080/api/stats/';
const response = await axios.get(api, axiosConfig);
console.log(response.data);
assert.equal(response.status, 200);
});