From 23323d33367ac71d9b9e3fe280a1220c6b917559 Mon Sep 17 00:00:00 2001 From: Roland Kakonyi Date: Tue, 28 Nov 2023 15:41:20 +0100 Subject: [PATCH] feat(playertesting): add more meaningful tests --- integration_test/tests/exampleSpec.ts | 33 +++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/integration_test/tests/exampleSpec.ts b/integration_test/tests/exampleSpec.ts index 826d7fe5..0f293af4 100644 --- a/integration_test/tests/exampleSpec.ts +++ b/integration_test/tests/exampleSpec.ts @@ -1,16 +1,39 @@ import { TestScope } from 'cavy'; -import { loadSourceConfig, playFor, startPlayerTest } from '../playertesting'; +import { + callPlayerAndExpectEvents, + EventSequence, + EventType, + expectEvents, + loadSourceConfig, + RepeatedEvent, + startPlayerTest, +} from '../playertesting'; import { SourceType } from 'bitmovin-player-react-native'; - export default (spec: TestScope) => { - spec.describe('player', () => { - spec.it('loads source and plays for 5 seconds', async () => { + spec.describe('calling play when a source is loaded', () => { + spec.it('emits a Play and Playing event', async () => { await startPlayerTest({}, async () => { await loadSourceConfig({ url: 'https://bitmovin-a.akamaihd.net/content/MI201109210084_1/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.m3u8', type: SourceType.HLS, }); - await playFor(5); + await callPlayerAndExpectEvents((player) => { + player.play(); + }, EventSequence(EventType.Play, EventType.Playing)); + }); + }); + }); + spec.describe('playing a source', () => { + spec.it('emits TimeChanged events', async () => { + await startPlayerTest({}, async () => { + await loadSourceConfig({ + url: 'https://bitmovin-a.akamaihd.net/content/MI201109210084_1/m3u8s/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.m3u8', + type: SourceType.HLS, + }); + await callPlayerAndExpectEvents((player) => { + player.play(); + }, EventSequence(EventType.Play, EventType.Playing)); + await expectEvents(RepeatedEvent(EventType.TimeChanged, 5)); }); }); });