1 | #!/usr/bin/env ts-node
|
2 | "use strict";
|
3 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
4 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
5 | };
|
6 | Object.defineProperty(exports, "__esModule", { value: true });
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 | const blue_tape_1 = __importDefault(require("blue-tape"));
|
27 | const sinon_1 = __importDefault(require("sinon"));
|
28 | const wechaty_puppet_mock_1 = require("wechaty-puppet-mock");
|
29 | const wechaty_1 = require("./wechaty");
|
30 | blue_tape_1.default('Wechaty Plugin uninstaller should be called after wechaty.stop()', async (t) => {
|
31 | const spyPluginInstall = sinon_1.default.spy();
|
32 | const spyPluginUninstall = sinon_1.default.spy();
|
33 | const bot = new wechaty_1.Wechaty({ puppet: new wechaty_puppet_mock_1.PuppetMock() });
|
34 | const plugin = (_bot) => {
|
35 | spyPluginInstall();
|
36 | return () => {
|
37 | spyPluginUninstall();
|
38 | };
|
39 | };
|
40 | t.true(spyPluginInstall.notCalled, 'should be clean for install spy');
|
41 | t.true(spyPluginUninstall.notCalled, 'should be clean for uninstall spy');
|
42 | bot.use(plugin);
|
43 | t.true(spyPluginInstall.called, 'should called install spy after use()');
|
44 | t.true(spyPluginUninstall.notCalled, 'should not call uninstall spy after use()');
|
45 | await bot.start();
|
46 | await bot.stop();
|
47 | t.true(spyPluginUninstall.called, 'should called uninstall spy after stop()');
|
48 | });
|
49 |
|
\ | No newline at end of file |