add test for bot signal
This commit is contained in:
parent
5dc6aa5660
commit
6e71ba4b5b
@ -157,6 +157,10 @@ export const mockGetGroupUsers = jest.fn(() => {
|
||||
|
||||
export const mockGetUser = jest.fn().mockReturnValue({ presence: 'online'});
|
||||
|
||||
export const mockSendStateEvent = jest.fn(() => {
|
||||
return Promise.resolve();
|
||||
});
|
||||
|
||||
export const mockClient = {
|
||||
registerRequest: mockRegisterRequest,
|
||||
initCrypto: mockInitCrypto,
|
||||
@ -186,6 +190,7 @@ export const mockClient = {
|
||||
getJoinedRoomMembers: mockGetJoinedRoomMembers,
|
||||
getUser: mockGetUser,
|
||||
getGroupUsers: mockGetGroupUsers,
|
||||
sendStateEvent: mockSendStateEvent,
|
||||
}
|
||||
|
||||
export const WebStorageSessionStore = jest.fn()
|
||||
|
@ -32,7 +32,8 @@ import {
|
||||
mockKick,
|
||||
mockGetJoinedRoomMembers,
|
||||
mockGetUser,
|
||||
mockGetGroupUsers
|
||||
mockGetGroupUsers,
|
||||
mockSendStateEvent,
|
||||
} from "matrix-js-sdk";
|
||||
|
||||
import OcrccBot from './bot'
|
||||
@ -100,6 +101,7 @@ describe('OcrccBot', () => {
|
||||
mockSendTextMessage.mockClear()
|
||||
mockAppendFileSync.mockClear()
|
||||
mockGetGroupUsers.mockClear()
|
||||
mockSendStateEvent.mockClear()
|
||||
})
|
||||
|
||||
|
||||
@ -325,4 +327,17 @@ describe('OcrccBot', () => {
|
||||
expect(mockStartClient).toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
test('#sendBotSignal should send custom state event', () => {
|
||||
const bot = new OcrccBot(botConfig)
|
||||
bot.start()
|
||||
const test_room_id = 'test_room_id'
|
||||
const signal = 'END_CHAT'
|
||||
|
||||
bot.sendBotSignal(test_room_id, signal)
|
||||
|
||||
waitForExpect(() => {
|
||||
expect(mockSendStateEvent).toHaveBeenCalledWith(test_room_id, 'm.bot.signal', { signal })
|
||||
})
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue
Block a user