UNPKG

1.44 kBPlain TextView Raw
1#!/usr/bin/env -S node --no-warnings --loader ts-node/esm
2/**
3 * Wechaty Chatbot SDK - https://github.com/wechaty/wechaty
4 *
5 * @copyright 2016 Huan LI (李卓桓) <https://github.com/huan>, and
6 * Wechaty Contributors <https://github.com/wechaty>.
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 *
20 */
21import { test } from 'tstest'
22import { WechatyBuilder } from './wechaty-builder.js'
23
24import { Io } from './io.js'
25
26test('Io restart without problem', async t => {
27 const io = new Io({
28 // token must not contain any white spaces
29 servicePort : 8788,
30 token : 'mock_00000000-0000-0000-0000-000000000000',
31 wechaty : WechatyBuilder.build(),
32 })
33
34 try {
35 for (let i = 0; i < 2; i++) {
36 await io.start()
37 await io.stop()
38 t.pass('start/stop-ed at #' + i)
39 }
40 t.pass('start/restart successed.')
41 } catch (e) {
42 t.fail(e as any)
43 }
44})