Skip to content

Commit

Permalink
Update prop types
Browse files Browse the repository at this point in the history
  • Loading branch information
retyui committed May 1, 2019
1 parent a9aece8 commit 5008608
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ declare module 'react-native-video' {
declare export type VideoProps = $ReadOnly<{
source: VideoSource, // Required prop

controls?: boolean,
audioOnly?: boolean,
id?: string, // for Web platform
maxBitRate?: number,
Expand All @@ -192,16 +193,21 @@ declare module 'react-native-video' {

// IOS only
allowsExternalPlayback?: boolean,
controls?: boolean, // and Web platform
filter?: $Values<FilterTypes>,
filterEnabled?: boolean,
fullscreen?: boolean,
fullscreenAutorotate?: boolean,
fullscreenOrientation?: OrientationType,
ignoreSilentSwitch?: SilentSwitchType,
playWhenInactive?: boolean,
pictureInPicture?: boolean,
onPictureInPictureStatusChanged?: (
VideoEvent<{ isActive: boolean }>
) => void,
onRestoreUserInterfaceForPictureInPictureStop?: () => void,

// Android only
minLoadRetryCount?: number,
bufferConfig?: BufferConfigDescriptor,
hideShutterView?: boolean,
reportBandwidth?: number,
Expand Down Expand Up @@ -252,5 +258,8 @@ declare module 'react-native-video' {
// IOS only
save(): Promise<{ uri: string }>;
seek(seconds: number, toleranceIOS: number): void;
restoreUserInterfaceForPictureInPictureStopCompleted(
restored: boolean
): void;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ describe('public class methods', () => {
describe('should call presentFullscreenPlayer', () => {
video.presentFullscreenPlayer();
});
describe('should call restoreUserInterfaceForPictureInPictureStopCompleted', () => {
video.restoreUserInterfaceForPictureInPictureStopCompleted(true);
// $ExpectError: first argument must be boolean
video.restoreUserInterfaceForPictureInPictureStopCompleted('true');
});
});
describe('source prop', () => {
Expand Down Expand Up @@ -204,6 +211,7 @@ describe('boolean props', () => {
fullscreen={false}
fullscreenAutorotate={false}
playWhenInactive={false}
pictureInPicture={false}
/>;

<Video
Expand All @@ -219,6 +227,7 @@ describe('boolean props', () => {
fullscreen
fullscreenAutorotate
playWhenInactive
pictureInPicture
/>;
});
});
Expand Down Expand Up @@ -500,8 +509,39 @@ describe('events', () => {
(event.bitrate: number);
}}
/>;
<Video source={0} onError={() => {}} />;
<Video source={0} onError={undefined} />;
<Video source={0} onBandwidthUpdate={() => {}} />;
<Video source={0} onBandwidthUpdate={undefined} />;
});
});

describe('onPictureInPictureStatusChanged', () => {
it('should passes when used properly', () => {
<Video
source={0}
onPictureInPictureStatusChanged={event => {
// $ExpectError - read-only event and exact
event.abc = 123;

(event.target: number);
(event.isActive: boolean);
}}
/>;
<Video source={0} onPictureInPictureStatusChanged={() => {}} />;
<Video source={0} onPictureInPictureStatusChanged={undefined} />;
});
});

describe('onRestoreUserInterfaceForPictureInPictureStop', () => {
it('should passes when used properly', () => {
<Video
source={0}
onRestoreUserInterfaceForPictureInPictureStop={() => {}}
/>;

<Video
source={0}
onRestoreUserInterfaceForPictureInPictureStop={undefined}
/>;
});
});

Expand Down

0 comments on commit 5008608

Please sign in to comment.