UNPKG

aijinkela-wechaty

Version:

Wechaty is a RPA SDK for Chatbot Makers.

61 lines 2.38 kB
#!/usr/bin/env -S node --no-warnings --loader ts-node/esm import { test } from 'tstest'; import PuppetMock from 'wechaty-puppet-mock'; import { WechatyEventEmitter } from '../schemas/wechaty-events.js'; import { WechatyImpl, // WechatyConstructor, } from './wechaty-impl.js'; test('Wechaty interface', async (t) => { class WechatyImplementation extends WechatyEventEmitter { Contact; ContactSelf; Delay; Friendship; Image; Location; Message; MiniProgram; Post; Room; RoomInvitation; Tag; UrlLink; 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.UrlLink = {}; } } 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) => { const noOneLeft = true; t.ok(noOneLeft, 'should match Wechaty properties for every protected property'); }); test('options.puppet initialization', async (t) => { const puppet = new PuppetMock(); const wechaty = new 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