Update tests

This commit is contained in:
Bill Thornton 2022-12-01 11:18:26 -05:00
parent edb7fc6087
commit c4dcf099d9
4 changed files with 18 additions and 1 deletions

View File

@ -47,3 +47,11 @@ jest.mock('@react-navigation/native/lib/commonjs/useLinking.native', () => ({
/* Safe Area Context Mocks */
import mockSafeAreaContext from 'react-native-safe-area-context/jest/mock';
jest.mock('react-native-safe-area-context', () => mockSafeAreaContext);
/* UUID Mocks */
jest.mock('uuid', () => {
let value = 0;
return {
v4: () => `uuid-${value++}`
};
});

View File

@ -26,6 +26,7 @@ describe('DownloadModel', () => {
expect(download.apiKey).toBe('api-key');
expect(download.itemId).toBe('item-id');
expect(download.sessionId).toBe('uuid-0');
expect(download.serverId).toBe('server-id');
expect(download.serverUrl).toBe('https://example.com/');
@ -42,6 +43,6 @@ describe('DownloadModel', () => {
expect(download.localFilename).toBe('file name.mp4');
expect(download.localPath).toBe(`${DOCUMENT_DIRECTORY}server-id/item-id/`);
expect(download.uri).toBe(`${DOCUMENT_DIRECTORY}server-id/item-id/file%20name.mp4`);
expect(download.getStreamUrl('device-id').toString()).toBe('https://example.com/Videos/item-id/stream.mp4?deviceId=device-id&api_key=api-key&videoCodec=hevc%2Ch264&audioCodec=aac%2Cmp3%2Cac3%2Ceac3%2Cflac%2Calac&maxAudioChannels=6');
expect(download.getStreamUrl('device-id').toString()).toBe('https://example.com/Videos/item-id/stream.mp4?deviceId=device-id&api_key=api-key&playSessionId=uuid-0&videoCodec=hevc%2Ch264&audioCodec=aac%2Cmp3%2Cac3%2Ceac3%2Cflac%2Calac&maxAudioChannels=6');
});
});

View File

@ -33,6 +33,7 @@ exports[`DownloadScreen should render correctly 1`] = `
"itemId": "item-id",
"serverId": "server-id",
"serverUrl": "https://example.com/",
"sessionId": "uuid-0",
"title": "title",
},
Object {
@ -45,6 +46,7 @@ exports[`DownloadScreen should render correctly 1`] = `
"itemId": "item-id-2",
"serverId": "server-id",
"serverUrl": "https://test2.example.com/",
"sessionId": "uuid-1",
"title": "other title",
},
]

View File

@ -3,6 +3,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import { Jellyfin } from '@jellyfin/sdk';
import DownloadStore from '../DownloadStore';
import MediaStore from '../MediaStore';
import RootStore from '../RootStore';
@ -17,6 +19,10 @@ describe('RootStore', () => {
expect(store.isFullscreen).toBe(false);
expect(store.isReloadRequired).toBe(false);
expect(store.didPlayerCloseManually).toBe(true);
expect(store.sdk).toBeInstanceOf(Jellyfin);
expect(store.sdk.deviceInfo.id).toBe(store.deviceId);
expect(store.downloadStore).toBeInstanceOf(DownloadStore);
expect(store.mediaStore).toBeInstanceOf(MediaStore);
expect(store.serverStore).toBeInstanceOf(ServerStore);