UNPKG

@juzi/wechaty

Version:

Wechaty is a RPA SDK for Chatbot Makers.

94 lines 4.64 kB
#!/usr/bin/env -S node --no-warnings --loader ts-node/esm "use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const tstest_1 = require("tstest"); const wechaty_puppet_mock_1 = __importDefault(require("@juzi/wechaty-puppet-mock")); const wechaty_events_js_1 = require("../schemas/wechaty-events.js"); const wechaty_impl_js_1 = require("./wechaty-impl.js"); (0, tstest_1.test)('Wechaty interface', async (t) => { class WechatyImplementation extends wechaty_events_js_1.WechatyEventEmitter { Contact; ContactSelf; Delay; Friendship; Image; Location; Message; MiniProgram; Post; Room; RoomInvitation; Tag; TagGroup; UrlLink; Channel; ChannelCard; ConsultCard; PremiumOnlineAppointmentCard; Moment; CallRecord; ChatHistory; Wecom; DouyinOneClickPhoneCollection; ImSpecific; WxxdProduct; WxxdOrder; constructor() { super(); // this.puppet this.Contact = this.ContactSelf = this.Delay = this.Friendship = this.Image = this.Location = this.Message = this.MiniProgram = this.Post = this.Room = this.RoomInvitation = this.Tag = this.TagGroup = this.UrlLink = this.Channel = this.ChannelCard = this.ConsultCard = this.PremiumOnlineAppointmentCard = this.Moment = this.CallRecord = this.ChatHistory = this.Wecom = this.DouyinOneClickPhoneCollection = this.ImSpecific = this.WxxdProduct = this.WxxdOrder = {}; } } const WechatyTest = WechatyImplementation; const w = new WechatyTest(); w.on('message', (msg) => { msg.say('ok').catch(console.error); }); t.ok(typeof WechatyImplementation, 'should no typing error'); }); // test('ProtectedProperties', async t => { // won't work before wecom mixin // probably because node version change? // type NotExistInWechaty = Exclude<AllProtectedProperty, keyof WechatyImpl | `_${string}`> // type NotExistTest = NotExistInWechaty extends never ? true : false // const noOneLeft: NotExistTest = true // t.ok(noOneLeft, 'should match Wechaty properties for every protected property') // }) (0, tstest_1.test)('options.puppet initialization', async (t) => { const puppet = new wechaty_puppet_mock_1.default(); const wechaty = new wechaty_impl_js_1.WechatyImpl({ puppet }); t.throws(() => wechaty.puppet, 'should throw when access puppet getter before init()'); await wechaty.init(); t.doesNotThrow(() => wechaty.puppet, 'should not throw when access puppet getter after init()'); t.ok(wechaty.puppet, 'should exist puppet instance by setting the options.puppet'); }); //# sourceMappingURL=wechaty-impl.spec.js.map