fix tests
This commit is contained in:
@@ -19,7 +19,7 @@ const MAX_RETRIES = 3;
|
||||
class OcrccBot {
|
||||
constructor() {
|
||||
this.awaitingFacilitator = {};
|
||||
this.client = null;
|
||||
this.client = matrix.createClient(process.env.MATRIX_SERVER_URL);
|
||||
this.joinedRooms = [];
|
||||
this.activeChatrooms = {};
|
||||
}
|
||||
@@ -450,9 +450,8 @@ class OcrccBot {
|
||||
|
||||
start() {
|
||||
const localStorage = this.createLocalStorage();
|
||||
const tmpClient = matrix.createClient(process.env.MATRIX_SERVER_URL);
|
||||
|
||||
tmpClient
|
||||
this.client
|
||||
.login("m.login.password", {
|
||||
user: process.env.BOT_USERNAME,
|
||||
password: process.env.BOT_PASSWORD,
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
mockClearStores,
|
||||
mockOn,
|
||||
mockOnce,
|
||||
mockSendMessage,
|
||||
mockSendTextMessage,
|
||||
mockLogin,
|
||||
mockGetDevices,
|
||||
@@ -30,7 +31,8 @@ import {
|
||||
mockInvite,
|
||||
mockKick,
|
||||
mockGetJoinedRoomMembers,
|
||||
mockGetUser
|
||||
mockGetUser,
|
||||
mockGetGroupUsers
|
||||
} from "matrix-js-sdk";
|
||||
|
||||
import OcrccBot from './bot'
|
||||
@@ -63,13 +65,14 @@ describe('OcrccBot', () => {
|
||||
mockKick.mockClear()
|
||||
mockGetJoinedRoomMembers.mockClear()
|
||||
mockGetUser.mockClear()
|
||||
mockSendMessage.mockClear()
|
||||
mockSendTextMessage.mockClear()
|
||||
mockAppendFileSync.mockClear()
|
||||
mockGetGroupUsers.mockClear()
|
||||
})
|
||||
|
||||
test('constructor should inititialize matrix client', () => {
|
||||
test('constructor should inititialize class variables', () => {
|
||||
const bot = new OcrccBot()
|
||||
expect(createClient).toHaveBeenCalledWith(process.env.MATRIX_SERVER_URL)
|
||||
expect(bot.joinedRooms).toEqual([])
|
||||
expect(bot.awaitingFacilitator).toEqual({})
|
||||
expect(bot.activeChatrooms).toEqual({})
|
||||
@@ -99,7 +102,7 @@ describe('OcrccBot', () => {
|
||||
expect(mockSetDeviceVerified).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
waitForExpect(() => {
|
||||
expect(mockSendTextMessage).toHaveBeenCalledWith(testRoom, testMsg)
|
||||
expect(mockSendMessage).toHaveBeenCalledWith(testRoom, testMsg)
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user