提交 86cf599a 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)

fix unit test to follow new FriendRequest

上级 7e26cf9b
......@@ -30,7 +30,9 @@ import * as test from 'blue-tape'
import { PuppetPuppeteer } from './puppet-puppeteer'
import { Firer } from './firer'
const mockPuppetPuppeteer = {} as PuppetPuppeteer
const mockPuppetPuppeteer = {
userSelf: () => ({}),
} as any as PuppetPuppeteer
test('parseFriendConfirm()', async t => {
const contentList = [
......
......@@ -208,16 +208,16 @@ function parseRoomJoin(
async function checkRoomJoin(
this: PuppetPuppeteer,
m: PuppeteerMessage,
msg: PuppeteerMessage,
): Promise<boolean> {
const room = m.room()
const room = msg.room()
if (!room) {
log.warn('PuppetPuppeteerFirer', 'fireRoomJoin() `room` not found')
return false
}
const text = m.text()
const text = msg.text()
let inviteeList: string[], inviter: string
try {
......
......@@ -29,10 +29,11 @@ import Wechaty from '../wechaty'
import {
Puppet,
} from '../puppet/'
FriendRequestType,
} from '../puppet/'
import {
PuppetMock,
} from '../puppet-mock/'
} from '../puppet-mock/'
import PuppeteerContact from './puppeteer-contact'
import PuppeteerMessage from './puppeteer-message'
......@@ -55,9 +56,9 @@ test('PuppetPuppeteerFriendRequest.receive smoke testing', async t => {
fr.receive(rawObj.RecommendInfo)
t.true(typeof fr.payload === 'object', 'should has info object')
t.is(fr.hello, '我是群聊"Wechaty"的李卓桓.PreAngel', 'should has right request message')
t.true(fr.contact instanceof PuppeteerContact, 'should have a Contact instance')
t.is(fr.type as any, 'receive', 'should be receive type')
t.is(fr.hello(), '我是群聊"Wechaty"的李卓桓.PreAngel', 'should has right request message')
t.true(fr.contact() instanceof PuppeteerContact, 'should have a Contact instance')
t.is(fr.type(), FriendRequestType.RECEIVE, 'should be receive type')
})
test('PuppetPuppeteerFriendRequest.confirm smoke testing', async t => {
......@@ -89,6 +90,6 @@ test('PuppetPuppeteerFriendRequest.confirm smoke testing', async t => {
const contact = m.from()
fr.confirm(contact || new MyContact('xx'))
t.true(fr.contact instanceof PuppeteerContact, 'should have a Contact instance')
t.is(fr.type as any, 'confirm', 'should be confirm type')
t.true(fr.contact() instanceof PuppeteerContact, 'should have a Contact instance')
t.is(fr.type(), FriendRequestType.CONFIRM, 'should be confirm type')
})
......@@ -169,7 +169,7 @@ test('self()', async t => {
t.false(m.self(), 'should identify self message false when from a different fromId')
})
test.only('mentioned()', async t => {
test('mentioned()', async t => {
/* tslint:disable:max-line-length */
const rawObj11 = JSON.parse(`{"MsgId":"6475340302153501409","FromUserName":"@@9cdc696e490bd76c57e7dd54792dc1408e27d65e312178b1943e88579b7939f4","ToUserName":"@cd7d467d7464e8ff6b0acd29364654f3666df5d04551f6082bfc875f90a6afd2","MsgType":1,"Content":"@4c32c97337cbb325442c304d6a44e374:<br/>@_@","Status":3,"ImgStatus":1,"CreateTime":1489823176,"VoiceLength":0,"PlayLength":0,"FileName":"","FileSize":"","MediaId":"","Url":"","AppMsgType":0,"StatusNotifyCode":0,"StatusNotifyUserName":"","RecommendInfo":{"UserName":"","NickName":"","QQNum":0,"Province":"","City":"","Content":"","Signature":"","Alias":"","Scene":0,"VerifyFlag":0,"AttrStatus":0,"Sex":0,"Ticket":"","OpCode":0},"ForwardFlag":0,"AppInfo":{"AppID":"","Type":0},"HasProductId":0,"Ticket":"","ImgHeight":0,"ImgWidth":0,"SubMsgType":0,"NewMsgId":6475340302153502000,"OriContent":"","MMPeerUserName":"@@9cdc696e490bd76c57e7dd54792dc1408e27d65e312178b1943e88579b7939f4","MMDigest":"22acb030-ff09-11e6-8a73-cff62d9268c5:@_@","MMIsSend":false,"MMIsChatRoom":true,"MMUnread":true,"LocalID":"6475340302153501409","ClientMsgId":"6475340302153501409","MMActualContent":"@_@","MMActualSender":"@4c32c97337cbb325442c304d6a44e374","MMDigestTime":"15:46","MMDisplayTime":1489823176,"MMTime":"15:46"}`)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册