Skip to content

Commit

Permalink
fix: (xgplayer-flv) unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
王伟 authored and xiyuyizhi committed Apr 28, 2024
1 parent 0087911 commit 2e38d9c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions packages/xgplayer-flv/__tests__/flv.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ describe('Flv', () => {
const endOfStream = jest.fn()
const bufferDestroy = jest.fn()
const seamlessSwitch = jest.fn()
const isFull = jest.fn()
BufferService.mockImplementation(() => {
return {
reset: bufferServiceReset,
endOfStream,
seamlessSwitch,
isFull,
destroy: bufferDestroy
}
})
Expand Down Expand Up @@ -107,15 +109,15 @@ describe('Flv', () => {
})

test('load', async () => {
const flv = new Flv({ media })
const flv = new Flv({ media, isLive: true })
const emit = jest.spyOn(flv, 'emit')
await flv.load('url')
expect(bufferServiceReset).toHaveBeenCalled()
expect(seiServiceReset).toHaveBeenCalled()
expect(bandwidthServiceReset).toHaveBeenCalled()
expect(loaderCancel).toHaveBeenCalled()
expect(loaderLoad).toHaveBeenLastCalledWith({ url: 'url' })
expect(emit).toHaveBeenCalledWith(EVENT.LOAD_START, { url: 'url' })
expect(loaderLoad).toHaveBeenLastCalledWith({ url: 'url', "range": [] })
expect(emit).toHaveBeenCalledWith(EVENT.LOAD_START, { url: 'url', 'seamlessSwitching': false })
})

test('replay', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/xgplayer-hls/__tests__/services/buffer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe('BufferService', () => {
const append = jest.fn()
const remove = jest.fn()
const unbindMedia = jest.fn()
const bindMedia = jest.fn()
const bindMedia = jest.fn().mockImplementation(() => Promise.resolve(true));
const endOfStream = jest.fn()
const setLiveSeekableRange = jest.fn()
const updateDuration = jest.fn()
Expand Down

0 comments on commit 2e38d9c

Please sign in to comment.