import { Client } from './Client';
import 'mocha';
import { PinusWSClient } from 'pinus-robot-plugin';
import { expect } from 'chai';
import { addItemsIfNotEnough, checkSuccessResponse } from './CheckPatten';
import { DEBUG_MAGIC_WORD, AUCTION_SOURCE, CURRENCY_BY_TYPE, CURRENCY_TYPE, AUCTION_STAGE, DIVIDEND_STATUS, LOT_STATUS } from '../app/consts';

describe('gm测试', function () {
    let pinusClient: PinusWSClient;
    let roleInfo;
    // 装备最大等级
    const MAX_LV = 100;
    // 装备最大star
    const MAX_STAR = 12;
    // 装备最大品质
    const MAX_QUALITY = 5;

    before(function (done) {
        const c = new Client();
        const timer = setInterval(() => {
            if (c.client) {
                pinusClient = c.client;
                roleInfo = c.roleInfo;
                clearInterval(timer);
                done();
            }
        }, 500);
    });

    after(function (done) {
        pinusClient.disconnect();
        // disconnect 后等待 500ms，供服务器清理环境、退出频道等
        setTimeout(() => {
            done();
        }, 500);
    });

    // 请修改 gm/filter/tokenFilter 中的代码，将鉴权的代码注释掉，接口就能调用了
    it.skip('武将装备强化-升品-升星-到当前最高', function (done) {
        // 测试参数: roleId: "6inQ1FHeSb"; rid:19
        const roleId = roleInfo.roleId, hid = 19;
        pinusClient.request('gm.gmRoleHandler.upgradeHeroEPlace', { roleId, hid }, (res) => {
            checkSuccessResponse(res);
            expect(res.data.curHero.ePlace).to.be.an('array');
            res.data.curHero.ePlace.forEach(element => {
                expect(element.stones).to.be.an('array');
                // 小于等于最大lv
                expect(element.lv).to.lte(MAX_LV);
                // 等于最大quality
                expect(element.quality).to.eq(MAX_QUALITY);
                // 等于最大star
                expect(element.star).to.eq(MAX_STAR);
            });

            done();
        });
    });

});
