本文整理汇总了TypeScript中blue-tape.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: initPuppetAccessoryTest
class WechatyTest extends Wechaty {
public initPuppetAccessoryTest (puppet: Puppet): void {
return this.initPuppetAccessory(puppet)
}
}
test('Export of the Framework', async t => {
t.ok(Contact , 'should export Contact')
t.ok(Friendship , 'should export Friendship')
t.ok(IoClient , 'should export IoClient')
t.ok(Message , 'should export Message')
t.ok(Puppet , 'should export Puppet')
t.ok(Room , 'should export Room')
t.ok(Wechaty , 'should export Wechaty')
t.ok(log , 'should export log')
const bot = Wechaty.instance()
t.is(bot.version(true), require('../package.json').version,
'should return version as the same in package.json',
)
t.is(VERSION, require('../package.json').version,
'should export version in package.json',
)
})
test('Config setting', async t => {
t.ok(config , 'should export Config')
// t.ok(config.default.DEFAULT_PUPPET , 'should has DEFAULT_PUPPET')
})
test('event:start/stop', async t => {
示例2: contactRawPayloadParser
test('contactRawPayloadParser', async t => {
const PADCHAT_CONTACT_PAYLOAD_PERSONAL: PadchatContactPayload = {
msg_type : PadchatContactMsgType.Contact,
continue : PadchatContinue.Done,
ticket : '',
big_head : 'http://wx.qlogo.cn/mmhead/ver_1/xfCMmibHH74xGLoyeDFJadrZXX3eOEznPefiaCa3iczxZGMwPtDuSbRQKx3Xdm18un303mf0NFia3USY2nO2VEYILw/0',
city : 'Haidian',
country : 'CN',
intro : '',
label : '1',
nick_name : '梦君君',
provincia : 'Beijing',
py_initial : 'LJR',
remark : '女儿',
remark_py_initial : 'lijiaruibeizhu',
remark_quan_pin : 'LJRBZ',
sex : ContactGender.Female,
signature : 'Stay+Foolish',
small_head : 'http://wx.qlogo.cn/mmhead/ver_1/xfCMmibHH74xGLoyeDFJadrZXX3eOEznPefiaCa3iczxZGMwPtDuSbRQKx3Xdm18un303mf0NFia3USY2nO2VEYILw/132',
status : PadchatContactRoomStatus.Get,
stranger : 'v1_0468f2cd3f0efe7ca2589d57c3f9ba952a3789e41b6e78ee00ed53d1e6096b88@stranger',
user_name : 'mengjunjun001',
}
const PADCHAT_CONTACT_PAYLOAD_OFFICIAL: PadchatContactPayload = {
big_head : 'http://wx.qlogo.cn/mmhead/ver_1/TR8EDh3MgMsu20pxjrDPBpaGySuEAGf3MUuoeUOV2LiaqvZxeMqb1U7hgiciaQZBC8LYN0boVLCKOIYg71pxdl1fQabiaxsn7CnNeGWVrK3jSIY/0',
city : 'Haidian',
country : 'CN',
intro : 'CARPE+DIEM+-+if+not+us,+who?+if+not+now,+when?',
label : '',
message : '',
nick_name : '李卓桓',
provincia : 'Beijing',
py_initial : 'LZH',
quan_pin : 'lizhuohuan',
remark : '',
remark_py_initial : '',
remark_quan_pin : '',
sex : 0,
signature : 'CARPE+DIEM+-+if+not+us,+who?+if+not+now,+when?',
small_head : 'http://wx.qlogo.cn/mmhead/ver_1/TR8EDh3MgMsu20pxjrDPBpaGySuEAGf3MUuoeUOV2LiaqvZxeMqb1U7hgiciaQZBC8LYN0boVLCKOIYg71pxdl1fQabiaxsn7CnNeGWVrK3jSIY/132',
status : 0,
stranger : 'v1_cd6656d42f505e5ffbb7eab65fed448fc8f02eade29a873ec3e758c7553db424@stranger',
ticket : '',
user_name : 'gh_59d7c8ad720c',
}
const EXPECTED_CONTACT_PAYLOAD_PERSONAL: ContactPayload = {
id : 'mengjunjun001',
gender : ContactGender.Female,
type : ContactType.Personal,
alias : '女儿',
avatar : 'http://wx.qlogo.cn/mmhead/ver_1/xfCMmibHH74xGLoyeDFJadrZXX3eOEznPefiaCa3iczxZGMwPtDuSbRQKx3Xdm18un303mf0NFia3USY2nO2VEYILw/0',
city : 'Haidian',
name : '梦君君',
province : 'Beijing',
signature : 'Stay Foolish',
}
const EXPECTED_CONTACT_PAYLOAD_OFFICIAL: ContactPayload = {
id : 'gh_59d7c8ad720c',
gender : ContactGender.Unknown,
type : ContactType.Official,
alias : '',
avatar : 'http://wx.qlogo.cn/mmhead/ver_1/TR8EDh3MgMsu20pxjrDPBpaGySuEAGf3MUuoeUOV2LiaqvZxeMqb1U7hgiciaQZBC8LYN0boVLCKOIYg71pxdl1fQabiaxsn7CnNeGWVrK3jSIY/0',
city : 'Haidian',
name : '李卓桓',
province : 'Beijing',
signature : 'CARPE DIEM+-+if+not+us,+who?+if+not+now,+when?',
}
const resultPersonal = contactRawPayloadParser(PADCHAT_CONTACT_PAYLOAD_PERSONAL)
t.deepEqual(resultPersonal, EXPECTED_CONTACT_PAYLOAD_PERSONAL, 'should parse ContactPayload for personal account payload')
const resultOfficial = contactRawPayloadParser(PADCHAT_CONTACT_PAYLOAD_OFFICIAL)
t.deepEqual(resultOfficial, EXPECTED_CONTACT_PAYLOAD_OFFICIAL, 'should parse ContactPayload for official account payload')
t.throws(() => contactRawPayloadParser({} as any), 'should throw exception for invalid object')
t.throws(() => contactRawPayloadParser(undefined as any), 'should throw exception for undifined')
})
示例3: roomTopicEventMessageParser
} from '../padchat-schemas'
import { roomTopicEventMessageParser } from './room-event-topic-message-parser'
test('roomTopicEventMessageParser() EN-other-modify-topic', async t => {
const MESSAGE_PAYLOAD: PadchatMessagePayload = {
content : '"李卓桓" changed the group name to "新群名"',
continue : 1,
description : '',
from_user : '5354656522@chatroom',
msg_id : '1699332376319377977',
msg_source : '',
msg_type : 5,
status : 1,
sub_type : 10000,
timestamp : 1528656400,
to_user : 'wxid_5zj4i5htp9ih22',
uin : 1928023446,
}
const EXPECTED_EVENT: PuppetRoomTopicEvent = {
changerName : '李卓桓',
roomId : '5354656522@chatroom',
topic : '新群名',
}
const event = roomTopicEventMessageParser(MESSAGE_PAYLOAD)
t.deepEqual(event, EXPECTED_EVENT, 'should parse event')
})
test('roomTopicEventMessageParser() EN-bot-modify-topic', async t => {
const MESSAGE_PAYLOAD: PadchatMessagePayload = {
content : 'You changed the group name to "morning"',
示例4: roomLeaveEventMessageParser
import { roomLeaveEventMessageParser } from './room-event-leave-message-parser'
test('roomLeaveEventMessageParser() EN-bot-delete-other', async t => {
const MESSAGE_PAYLOAD: PadchatMessagePayload = {
content : 'You removed "李卓桓" from the group chat',
continue : 1,
description : '',
from_user : '6061139518@chatroom',
msg_id : '4444372134867544747',
msg_source : '',
msg_type : 5,
status : 1,
sub_type : 10000,
timestamp : 1528751382,
to_user : 'wxid_5zj4i5htp9ih22',
uin : 1928023446,
}
const EXPECTED_EVENT: PuppetRoomLeaveEvent = {
leaverNameList : ['李卓桓'],
removerName : YOU,
roomId : '6061139518@chatroom',
}
const payload = roomLeaveEventMessageParser(MESSAGE_PAYLOAD)
// console.log('payload:', payload)
t.deepEqual(payload, EXPECTED_EVENT, 'should parse room leave message payload')
})
test('roomLeaveEventMessageParser() EN-bot-delete-others', async t => {
t.skip('the same as bot-delete-other')
示例5: friendshipReceiveEventMessageParser
import test from 'blue-tape'
import {
PadchatMessagePayload,
} from '../padchat-schemas'
import { friendshipReceiveEventMessageParser } from './friendship-event-message-parser'
test('friendshipReceiveEventMessageParser()', async t => {
const MESSAGE_PAYLOAD: PadchatMessagePayload = {
content : '<msg fromusername="lizhuohuan" encryptusername="v1_cf269def9b946093f9d131a5e733ba169351013c95e46a860cddecaf485c4b10@stranger" fromnickname="李卓桓" content="xxxxx" fullpy="lizhuohuan" shortpy="LZH" imagestatus="3" scene="6" country="CN" province="Beijing" city="Haidian" sign="PreAngel投资人。水木清华BBS站长。投资人中最会飞的AI程序员。" percard="1" sex="1" alias="" weibo="" weibonickname="" albumflag="0" albumstyle="0" albumbgimgid="913943270785024_913943270785024" snsflag="177" snsbgimgid="http://shmmsns.qpic.cn/mmsns/NoFChqEQomEyhyNjzExH3v78BHSVmIzHBIdOECg9jgcTpRNwThgXJicCsGicI6Kib4xLETc2PuKwhM/0" snsbgobjectid="12683064081608282338" mhash="d98b28f4cb1708bb584f3e66078e0a0d" mfullhash="d98b28f4cb1708bb584f3e66078e0a0d" bigheadimgurl="http://wx.qlogo.cn/mmhead/ver_1/ciaaFRTCqfHIKLY0wBjv3h0LSPkCEEcJ0fo6kQkMxQLBiahJWFk7rS9G4VLU5n9OfAnXWlMaIV01oeTITYS0OHlg/0" smallheadimgurl="http://wx.qlogo.cn/mmhead/ver_1/ciaaFRTCqfHIKLY0wBjv3h0LSPkCEEcJ0fo6kQkMxQLBiahJWFk7rS9G4VLU5n9OfAnXWlMaIV01oeTITYS0OHlg/96" ticket="v2_1a0d2cf325e64b6f74bed09e944529e737463bf02371b86dd43b437342699179687b3467c4f1f0406fc5c8dbe725c037313bb8dca856ab0de85f433b43818860@stranger" opcode="2" googlecontact="" qrticket="" chatroomusername="" sourceusername="" sourcenickname=""><brandlist count="0" ver="652101899"></brandlist></msg>',
continue : 1,
description : '',
from_user : 'fmessage',
msg_id : '1323100839738523833',
msg_source : '',
msg_type : 5,
status : 1,
sub_type : 37,
timestamp : 1528786566,
to_user : 'wxid_5zj4i5htp9ih22',
uin : 1928023446,
}
const EXPECTED_CONTACT_ID = 'lizhuohuan'
const contactName = friendshipReceiveEventMessageParser(MESSAGE_PAYLOAD)
t.equal(contactName, EXPECTED_CONTACT_ID, 'should parse message to receive contact id')
})
示例6: catch
*/
// tslint:disable:no-shadowed-variable
import test from 'blue-tape'
import {
PuppetManager,
} from './puppet-manager'
test('resolve an unsupported puppet name', async t => {
try {
await PuppetManager.resolve('fasdfsfasfsfdfs' as any)
t.fail('should reject')
} catch (e) {
t.ok('reject when options is a string')
}
try {
await PuppetManager.resolve({ puppet: 'fadfdsafa' as any })
t.fail('should reject')
} catch (e) {
t.ok('reject when options.puppet is unknown')
}
try {
await PuppetManager.resolve({ puppet: 'mock' })
t.pass('should allow "mock" as puppet name')
} catch (e) {
t.fail('should pass "mock" as puppet name')
}
})
示例7: roomJoinEventMessageParser
} from '../padchat-schemas'
import { roomJoinEventMessageParser } from './room-event-join-message-parser'
test('roomJoinEventMessageParser() EN-other-invite-other', async t => {
const MESSAGE_PAYLOAD: PadchatMessagePayload = {
content : '李卓桓 invited Huan to the group chat',
continue : 1,
description : '',
from_user : '5967138682@chatroom',
msg_id : '11101130790981890',
msg_source : '',
msg_type : 5,
status : 1,
sub_type : 10000,
timestamp : 1528754090,
to_user : 'wxid_5zj4i5htp9ih22',
uin : 1928023446,
}
const EXPECTED_EVENT: PuppetRoomJoinEvent = {
inviteeNameList : ['Huan'],
inviterName : '李卓桓',
roomId : '5967138682@chatroom',
}
const event = roomJoinEventMessageParser(MESSAGE_PAYLOAD)
t.deepEqual(event, EXPECTED_EVENT, 'should parse event')
})
test('roomJoinEventMessageParser() EN-other-invite-others', async t => {
const MESSAGE_PAYLOAD: PadchatMessagePayload = {
content : '李卓桓 invited 李佳芮, Huan to the group chat',
示例8: getPort
// tslint:disable:no-shadowed-variable
import test from 'blue-tape'
// import http from 'http'
import express from 'express'
import { getPort } from './get-port'
test('getPort() for an available socket port', async t => {
const PORT = 8788
let port = await getPort(PORT)
let ttl = 17
const serverList = []
while (ttl-- > 0) {
try {
const app = express()
const server = app.listen(port)
port = await getPort(PORT)
serverList.push(server)
} catch (e) {
t.fail('should not exception: ' + e.message + ', ' + e.stack)
}
}
serverList.map(server => server.close())
t.pass('should has no exception after loop test')
})
示例9: roomLeaveEventMessageParser
import { roomLeaveEventMessageParser } from './room-event-leave-message-parser'
test('roomLeaveEventMessageParser() ZH-bot-delete-other', async t => {
const MESSAGE_PAYLOAD: PadchatMessagePayload = {
content : '你将"Huan LI++"移出了群聊',
continue : 1,
description : '',
from_user : '5354656522@chatroom',
msg_id : '7593234909679768634',
msg_source : '',
msg_type : 5,
status : 1,
sub_type : 10000,
timestamp : 1528657235,
to_user : 'lizhuohuan',
uin : 4763975,
}
const EXPECTED_EVENT: PuppetRoomLeaveEvent = {
leaverNameList : ['Huan LI++'],
removerName : YOU,
roomId : '5354656522@chatroom',
}
const payload = roomLeaveEventMessageParser(MESSAGE_PAYLOAD)
// console.log('payload:', payload)
t.deepEqual(payload, EXPECTED_EVENT, 'should parse room leave message payload')
})
test('roomLeaveEventMessageParser() ZH-bot-delete-others', async t => {
t.skip('the same as bot-delete-other')
示例10:
import test from 'blue-tape'
import {
stripBugChatroomId,
} from './compatible-wei-bug'
test('stripBugChatroomId()', async t => {
const RAW_USER_NAME_1 = '\n\u00135907139882@chatroom'
const USER_NAME_1 = '5907139882@chatroom'
const RAW_USER_NAME_2 = '\n\u001412558026334@chatroom'
const USER_NAME_2 = '12558026334@chatroom'
t.equal(stripBugChatroomId(RAW_USER_NAME_1) , USER_NAME_1, 'should return pure user_name for RAW_USER_NAME_1')
t.equal(stripBugChatroomId(RAW_USER_NAME_2) , USER_NAME_2, 'should return pure user_name for RAW_USER_NAME_2')
t.equal(stripBugChatroomId(undefined) , '', 'should return empty string for undifined')
})