Skip to content

Commit

Permalink
Set timeout for tests about soffice
Browse files Browse the repository at this point in the history
  • Loading branch information
yhatt committed Jan 21, 2025
1 parent a3f61e3 commit 8542e94
Showing 1 changed file with 25 additions and 17 deletions.
42 changes: 25 additions & 17 deletions test/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1111,27 +1111,35 @@ describe('Converter', () => {
timeoutLarge
)

it('throws an error when soffice is not found', async () => {
const err = new CLIError('Error', CLIErrorCode.NOT_FOUND_SOFFICE)
it(
'throws an error when soffice is not found',
async () => {
const err = new CLIError('Error', CLIErrorCode.NOT_FOUND_SOFFICE)

jest.spyOn(console, 'warn').mockImplementation()
jest.spyOn(sofficeFinder, 'findSOffice').mockRejectedValue(err)
jest.spyOn(console, 'warn').mockImplementation()
jest.spyOn(sofficeFinder, 'findSOffice').mockRejectedValue(err)

const cvt = converter({ pptxEditable: true })
await expect(() =>
cvt.convertFile(new File(onePath))
).rejects.toThrow(err)
})
const cvt = converter({ pptxEditable: true })
await expect(() =>
cvt.convertFile(new File(onePath))
).rejects.toThrow(err)
},
timeout
)

it('throws an error when soffice is spawned but does not generate a converted file', async () => {
jest.spyOn(console, 'warn').mockImplementation()
jest.spyOn(SOffice.prototype, 'spawn').mockResolvedValue()
it(
'throws an error when soffice is spawned but does not generate a converted file',
async () => {
jest.spyOn(console, 'warn').mockImplementation()
jest.spyOn(SOffice.prototype, 'spawn').mockResolvedValue()

const cvt = converter({ pptxEditable: true })
await expect(() =>
cvt.convertFile(new File(onePath))
).rejects.toThrow('LibreOffice could not convert PPTX internally.')
})
const cvt = converter({ pptxEditable: true })
await expect(() =>
cvt.convertFile(new File(onePath))
).rejects.toThrow('LibreOffice could not convert PPTX internally.')
},
timeout
)
})
})

Expand Down

0 comments on commit 8542e94

Please sign in to comment.