catch bot rate limiting error, update tests
This commit is contained in:
@@ -35,8 +35,11 @@ import {
|
||||
|
||||
import OcrccBot from './bot'
|
||||
|
||||
describe('OcrccBot', () => {
|
||||
|
||||
const mockAppendFileSync = jest.fn()
|
||||
fs.appendFileSync = mockAppendFileSync
|
||||
|
||||
describe('OcrccBot', () => {
|
||||
beforeEach(() => {
|
||||
createClient.mockClear()
|
||||
mockInitCrypto.mockClear()
|
||||
@@ -61,6 +64,7 @@ describe('OcrccBot', () => {
|
||||
mockGetJoinedRoomMembers.mockClear()
|
||||
mockGetUser.mockClear()
|
||||
mockSendTextMessage.mockClear()
|
||||
mockAppendFileSync.mockClear()
|
||||
})
|
||||
|
||||
test('constructor should inititialize matrix client', () => {
|
||||
@@ -196,11 +200,10 @@ describe('OcrccBot', () => {
|
||||
})
|
||||
|
||||
test('#writeToTranscript should parse event and write to transcript file', () => {
|
||||
const appendFileSyncSpy = jest.spyOn(fs, 'appendFileSync')
|
||||
const bot = new OcrccBot()
|
||||
bot.start()
|
||||
|
||||
bot.activeChatrooms['test_room_id'] = { transcriptFile: 'test filepath' }
|
||||
bot.activeChatrooms['test_room_id'] = { transcriptFile: '__mocks__/test_transcript.txt' }
|
||||
|
||||
waitForExpect(() => {
|
||||
expect(mockStartClient).toHaveBeenCalled()
|
||||
@@ -216,7 +219,7 @@ describe('OcrccBot', () => {
|
||||
bot.writeToTranscript(mockEvent)
|
||||
|
||||
waitForExpect(() => {
|
||||
expect(appendFileSyncSpy).toHaveBeenCalledWith('test filepath', 'test_sender [00:00:00]: test content', 'utf8')
|
||||
expect(mockAppendFileSync).toHaveBeenCalledWith('__mocks__/test_transcript.txt', 'test_sender [00:00:00]: test content', 'utf8')
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user