测试:mocha 基础文件
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
module.exports = {
|
||||||
|
'development': {
|
||||||
|
'mongo': 'mongodb://dbop:zyzdbopbantu@dds-8vbdb47c6fb58a541.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vbdb47c6fb58a542.mongodb.zhangbei.rds.aliyuncs.com:3717/zyz?replicaSet=mgset-500808098',
|
||||||
|
'redis': 'r-8vb4i2kgl91886fkxd.redis.zhangbei.rds.aliyuncs.com'
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -11,21 +11,26 @@
|
|||||||
"cov": "nyc mocha",
|
"cov": "nyc mocha",
|
||||||
"ci": "yarn run test",
|
"ci": "yarn run test",
|
||||||
"gen-api-ref": "node ../../../node_modules/typedoc/bin/typedoc --mode file --hideGenerator --excludeExternals --ignoreCompilerErrors --out ../../../run/site/public/api-reference/pinus-loader lib/",
|
"gen-api-ref": "node ../../../node_modules/typedoc/bin/typedoc --mode file --hideGenerator --excludeExternals --ignoreCompilerErrors --out ../../../run/site/public/api-reference/pinus-loader lib/",
|
||||||
"local": "npm run build && cd dist && pinus start"
|
"local": "npm run build && cd dist && pinus start",
|
||||||
|
"jenkins": "npm run build && cd dist && pinus start -D"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@typegoose/typegoose": "^7.3.5",
|
"@typegoose/typegoose": "^7.3.5",
|
||||||
"@types/bluebird": "^3.5.19",
|
"@types/bluebird": "^3.5.19",
|
||||||
|
"@types/chai": "^4.2.14",
|
||||||
"@types/crc": "^3.4.0",
|
"@types/crc": "^3.4.0",
|
||||||
|
"@types/mocha": "^8.2.0",
|
||||||
"@types/mongoose": "^5.7.36",
|
"@types/mongoose": "^5.7.36",
|
||||||
"@types/node": "8.10.54",
|
"@types/node": "8.10.54",
|
||||||
"@types/redis": "^2.8.25",
|
"@types/redis": "^2.8.25",
|
||||||
"@types/underscore": "^1.10.24",
|
"@types/underscore": "^1.10.24",
|
||||||
"bcrypt": "^5.0.0",
|
"bcrypt": "^5.0.0",
|
||||||
"bluebird": "^3.5.1",
|
"bluebird": "^3.5.1",
|
||||||
|
"chai": "^4.2.0",
|
||||||
"crc": "^3.5.0",
|
"crc": "^3.5.0",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"local": "^0.3.3",
|
"local": "^0.3.3",
|
||||||
|
"mocha": "^8.2.1",
|
||||||
"moment": "^2.29.1",
|
"moment": "^2.29.1",
|
||||||
"mongoose": "^5.10.4",
|
"mongoose": "^5.10.4",
|
||||||
"mongoose-transactions": "^1.1.4",
|
"mongoose-transactions": "^1.1.4",
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
import 'mocha';
|
||||||
|
import { PinusWSClient, PinusWSClientEvent } from 'pinus-robot-plugin';
|
||||||
|
import { expect } from 'chai';
|
||||||
|
describe('test zyz login', function() {
|
||||||
|
// it('异步请求应该返回一个对象', function(done){
|
||||||
|
// request
|
||||||
|
// .get('https://api.github.com')
|
||||||
|
// .end(function(err, res){
|
||||||
|
// expect(res).to.be.an('object');
|
||||||
|
// done();
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
var pinusClient;
|
||||||
|
|
||||||
|
beforeEach(function(done) {
|
||||||
|
pinusClient = new PinusWSClient();
|
||||||
|
pinusClient.on(PinusWSClientEvent.EVENT_IO_ERROR, (event) => {
|
||||||
|
// 错误处理
|
||||||
|
// console.error('error', event);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
pinusClient.on(PinusWSClientEvent.EVENT_CLOSE, function(event) {
|
||||||
|
// 关闭处理
|
||||||
|
// console.error('close', event);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
pinusClient.on(PinusWSClientEvent.EVENT_HEART_BEAT_TIMEOUT, function(event) {
|
||||||
|
// 心跳timeout
|
||||||
|
// console.error('heart beat timeout', event);
|
||||||
|
});
|
||||||
|
pinusClient.on(PinusWSClientEvent.EVENT_KICK, function(event) {
|
||||||
|
// 踢出
|
||||||
|
// console.error('kick', event);
|
||||||
|
});
|
||||||
|
let host = '127.0.0.1';
|
||||||
|
let port = '3050';
|
||||||
|
pinusClient.init({
|
||||||
|
host: host,
|
||||||
|
port: port
|
||||||
|
}, (data) => {
|
||||||
|
// 连接成功执行函数
|
||||||
|
console.log('gate连接成功', data);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(function(done) {
|
||||||
|
pinusClient.disconnect();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('登录测试', function(done) {
|
||||||
|
expect(1).equal(1);
|
||||||
|
pinusClient.request('connector.entryHandler.enter', {token:'mgn0njiajb6kapid3eekvt7tssxelig9zi2oq2bzkxr4zzi9w9', serverId: 1} , (ret) => {
|
||||||
|
// 消息回调
|
||||||
|
console.log('connector返回', JSON.stringify(ret));
|
||||||
|
expect(ret).to.be.an('object');
|
||||||
|
expect(ret.code).equal(0);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
import 'mocha';
|
||||||
|
import { PinusWSClient, PinusWSClientEvent } from 'pinus-robot-plugin';
|
||||||
|
import { expect } from 'chai';
|
||||||
|
describe('寻宝创建队伍', function() {
|
||||||
|
// it('异步请求应该返回一个对象', function(done){
|
||||||
|
// request
|
||||||
|
// .get('https://api.github.com')
|
||||||
|
// .end(function(err, res){
|
||||||
|
// expect(res).to.be.an('object');
|
||||||
|
// done();
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
var pinusClient;
|
||||||
|
var roleInfo;
|
||||||
|
|
||||||
|
beforeEach(function(done) {
|
||||||
|
pinusClient = new PinusWSClient();
|
||||||
|
pinusClient.on(PinusWSClientEvent.EVENT_IO_ERROR, (event) => {
|
||||||
|
// 错误处理
|
||||||
|
// console.error('error', event);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
pinusClient.on(PinusWSClientEvent.EVENT_CLOSE, function(event) {
|
||||||
|
// 关闭处理
|
||||||
|
// console.error('close', event);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
pinusClient.on(PinusWSClientEvent.EVENT_HEART_BEAT_TIMEOUT, function(event) {
|
||||||
|
// 心跳timeout
|
||||||
|
// console.error('heart beat timeout', event);
|
||||||
|
});
|
||||||
|
pinusClient.on(PinusWSClientEvent.EVENT_KICK, function(event) {
|
||||||
|
// 踢出
|
||||||
|
// console.error('kick', event);
|
||||||
|
});
|
||||||
|
let host = '127.0.0.1';
|
||||||
|
let port = '3050';
|
||||||
|
pinusClient.init({
|
||||||
|
host: host,
|
||||||
|
port: port
|
||||||
|
}, (data) => {
|
||||||
|
// 连接成功执行函数
|
||||||
|
console.log('gate连接成功', data);
|
||||||
|
// done();
|
||||||
|
pinusClient.request('connector.entryHandler.enter', {token:'mgn0njiajb6kapid3eekvt7tssxelig9zi2oq2bzkxr4zzi9w9', serverId: 1} , (ret) => {
|
||||||
|
// 消息回调
|
||||||
|
console.log('connector返回', JSON.stringify(ret));
|
||||||
|
roleInfo = ret.role;
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(function(done) {
|
||||||
|
pinusClient.disconnect();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('直接返回队伍', function(done) {
|
||||||
|
pinusClient.request('battle.comBattleHandler.createTeam', {blueprtId: 33001, pub: true, ceLimit: 0}, (res) => {
|
||||||
|
expect(res).to.be.an('object');
|
||||||
|
expect(res.code).equal(0);
|
||||||
|
expect(res.data).to.be.an('object');
|
||||||
|
expect(res.data.teamCode).to.be.a('string');
|
||||||
|
expect(res.data.roleStatus).to.be.an('array');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
import 'mocha';
|
||||||
|
import { expect } from 'chai';
|
||||||
|
import { resResult } from '../app/pubUtils/util';
|
||||||
|
describe('测试 ts', function() {
|
||||||
|
it('用例1', function() {
|
||||||
|
const result = resResult({code: 0, simStr: 'hello'});
|
||||||
|
console.log('ltc result: ', result);
|
||||||
|
expect(result).to.be.an('object');
|
||||||
|
expect(result.code).equal(0);
|
||||||
|
expect(result.msg).equal('hello');
|
||||||
|
})
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user