diff --git a/integration_test/index.test.js b/integration_test/index.test.js index ce6a731a..e6b0da08 100644 --- a/integration_test/index.test.js +++ b/integration_test/index.test.js @@ -1,8 +1,8 @@ import { AppRegistry } from 'react-native'; import TestableApp from './src/TestableApp'; -import PlayerWorld from './playertesting/PlayerWorld'; +import PlayerTestWorld from './playertesting/PlayerTestWorld'; import { name as appName, licenseKey } from './app.json'; -PlayerWorld.defaultLicenseKey = licenseKey; +PlayerTestWorld.defaultLicenseKey = licenseKey; AppRegistry.registerComponent(appName, () => TestableApp); diff --git a/integration_test/playertesting/PlayerWorld.ts b/integration_test/playertesting/PlayerTestWorld.ts similarity index 94% rename from integration_test/playertesting/PlayerWorld.ts rename to integration_test/playertesting/PlayerTestWorld.ts index 9a4e919e..a5b77660 100644 --- a/integration_test/playertesting/PlayerWorld.ts +++ b/integration_test/playertesting/PlayerTestWorld.ts @@ -18,22 +18,22 @@ import { EventSequence, } from './expectations/MultipleEventsExpectation'; -export default class PlayerWorld { +export default class PlayerTestWorld { static defaultLicenseKey: string | undefined; - private static shared_: PlayerWorld | undefined; + private static shared_: PlayerTestWorld | undefined; private player_: Player | undefined; private isFinished_: boolean = false; private eventListeners: { [key: string]: (event: Event) => void } = {}; - static get shared(): PlayerWorld { - if (PlayerWorld.shared_ === undefined) { - throw new Error('PlayerWorld.shared not initialized'); + static get shared(): PlayerTestWorld { + if (PlayerTestWorld.shared_ === undefined) { + throw new Error('PlayerTestWorld.shared not initialized'); } - return PlayerWorld.shared_; + return PlayerTestWorld.shared_; } - static set shared(playerWorld: PlayerWorld | undefined) { - PlayerWorld.shared_ = playerWorld; + static set shared(playerTestWorld: PlayerTestWorld | undefined) { + PlayerTestWorld.shared_ = playerTestWorld; } get player(): Player | undefined { @@ -62,7 +62,7 @@ export default class PlayerWorld { fn: () => Promise ): Promise => { if (config.licenseKey === undefined) { - config.licenseKey = PlayerWorld.defaultLicenseKey; + config.licenseKey = PlayerTestWorld.defaultLicenseKey; } const player = new Player({ diff --git a/integration_test/playertesting/PlayerTesting.ts b/integration_test/playertesting/PlayerTesting.ts index f9e39218..3a06f30b 100644 --- a/integration_test/playertesting/PlayerTesting.ts +++ b/integration_test/playertesting/PlayerTesting.ts @@ -7,7 +7,7 @@ import { TimeChangedEvent, } from 'bitmovin-player-react-native'; import { EventType } from './EventType'; -import PlayerWorld from './PlayerWorld'; +import PlayerTestWorld from './PlayerTestWorld'; import { SingleEventExpectation, MultipleEventsExpectation, @@ -31,7 +31,7 @@ export const startPlayerTest = async ( config: PlayerConfig, fn: () => Promise ): Promise => { - return await PlayerWorld.shared.startPlayerTest(config, fn); + return await PlayerTestWorld.shared.startPlayerTest(config, fn); }; /** @@ -49,7 +49,7 @@ export const startPlayerTest = async ( export const callPlayer = async ( fn: (player: Player) => Promise ): Promise => { - return await PlayerWorld.shared.callPlayer(fn); + return await PlayerTestWorld.shared.callPlayer(fn); }; /** @@ -72,7 +72,7 @@ export const expectEvent = async ( expectationConvertible: SingleEventExpectation | EventType, timeoutSeconds: number = 10 ): Promise => { - return await PlayerWorld.shared.expectEvent( + return await PlayerTestWorld.shared.expectEvent( expectationConvertible, timeoutSeconds ); @@ -104,7 +104,7 @@ export const expectEvents = async ( expectationsConvertible: MultipleEventsExpectation | EventType[], timeoutSeconds: number = 10 ): Promise => { - return await PlayerWorld.shared.expectEvents( + return await PlayerTestWorld.shared.expectEvents( expectationsConvertible, timeoutSeconds ); @@ -131,7 +131,7 @@ export const callPlayerAndExpectEvent = async ( expectationConvertible: SingleEventExpectation | EventType, timeoutSeconds: number = 10 ): Promise => { - return await PlayerWorld.shared.callPlayerAndExpectEvent( + return await PlayerTestWorld.shared.callPlayerAndExpectEvent( fn, expectationConvertible, timeoutSeconds @@ -165,7 +165,7 @@ export const callPlayerAndExpectEvents = async ( expectationsConvertible: MultipleEventsExpectation | EventType[], timeoutSeconds: number = 10 ): Promise => { - return await PlayerWorld.shared.callPlayerAndExpectEvents( + return await PlayerTestWorld.shared.callPlayerAndExpectEvents( fn, expectationsConvertible, timeoutSeconds @@ -193,7 +193,7 @@ export const loadSourceConfig = async ( sourceConfig: SourceConfig, timeoutSeconds: number = 10 ): Promise => { - return await PlayerWorld.shared.loadSourceConfig( + return await PlayerTestWorld.shared.loadSourceConfig( sourceConfig, timeoutSeconds ); @@ -215,7 +215,7 @@ export const playFor = async ( time: number, timeoutSeconds: number = 10 ): Promise => { - return await PlayerWorld.shared.playFor(time, timeoutSeconds); + return await PlayerTestWorld.shared.playFor(time, timeoutSeconds); }; /** @@ -234,5 +234,5 @@ export const playUntil = async ( time: number, timeoutSeconds: number = 10 ): Promise => { - return await PlayerWorld.shared.playUntil(time, timeoutSeconds); + return await PlayerTestWorld.shared.playUntil(time, timeoutSeconds); }; diff --git a/integration_test/playertesting/expectations/MultipleEventsExpectation.ts b/integration_test/playertesting/expectations/MultipleEventsExpectation.ts index 758d83fc..86a93117 100644 --- a/integration_test/playertesting/expectations/MultipleEventsExpectation.ts +++ b/integration_test/playertesting/expectations/MultipleEventsExpectation.ts @@ -164,7 +164,7 @@ export function EventBag( export function RepeatedEvent( singleExpectationConvertible: SingleEventExpectation | EventType, count: number -): EventSequenceExpectation { +): RepeatedEventExpectation { return new RepeatedEventExpectation(singleExpectationConvertible, count); } diff --git a/integration_test/src/TestableApp.tsx b/integration_test/src/TestableApp.tsx index c7792400..4a24594b 100644 --- a/integration_test/src/TestableApp.tsx +++ b/integration_test/src/TestableApp.tsx @@ -1,19 +1,19 @@ import React, { useEffect, useState } from 'react'; import { Tester, TestHookStore } from 'cavy'; import Specs from '../tests'; -import PlayerWorld from '../playertesting/PlayerWorld'; +import PlayerTestWorld from '../playertesting/PlayerTestWorld'; import TestablePlayer from './TestablePlayer'; const testHookStore = new TestHookStore(); function TestableApp(): JSX.Element { - const playerWorld = useState(new PlayerWorld())[0]; + const playerTestWorld = useState(new PlayerTestWorld())[0]; useEffect(() => { - PlayerWorld.shared = playerWorld; + PlayerTestWorld.shared = playerTestWorld; return () => { - PlayerWorld.shared = undefined; + PlayerTestWorld.shared = undefined; }; - }, [playerWorld]); + }, [playerTestWorld]); return ( - + ); } diff --git a/integration_test/src/TestablePlayer.tsx b/integration_test/src/TestablePlayer.tsx index 04199d37..2b99ad8f 100644 --- a/integration_test/src/TestablePlayer.tsx +++ b/integration_test/src/TestablePlayer.tsx @@ -2,37 +2,37 @@ import React, { useState } from 'react'; import { useCavy, wrap } from 'cavy'; import { SafeAreaView, StyleSheet, Text } from 'react-native'; import { PlayerView } from 'bitmovin-player-react-native'; -import PlayerWorld from '../playertesting/PlayerWorld'; +import PlayerTestWorld from '../playertesting/PlayerTestWorld'; import { Colors } from 'react-native/Libraries/NewAppScreen'; interface TestablePlayerProps { - playerWorld: PlayerWorld; + playerTestWorld: PlayerTestWorld; } export default function TestablePlayer({ - playerWorld, + playerTestWorld, }: TestablePlayerProps): JSX.Element { const generateTestHook = useCavy(); const [renderCount, setRenderCount] = useState(0); - playerWorld.onReRender = () => setRenderCount((count) => count + 1); + playerTestWorld.onReRender = () => setRenderCount((count) => count + 1); const TestablePlayerView = wrap(PlayerView); return ( - {(playerWorld.player && ( + {(playerTestWorld.player && ( <> Tests are running...🧪 )) || ( - {playerWorld.isFinished + {playerTestWorld.isFinished ? 'Tests have finished!' : 'Waiting for tests to start...'}