diff --git a/jest.setup.js b/jest.setup.js index 6b17417..279d72f 100644 --- a/jest.setup.js +++ b/jest.setup.js @@ -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++}` + }; +}); diff --git a/models/__tests__/DownloadModel.test.js b/models/__tests__/DownloadModel.test.js index dee3454..ebfa6d1 100644 --- a/models/__tests__/DownloadModel.test.js +++ b/models/__tests__/DownloadModel.test.js @@ -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'); }); }); diff --git a/screens/__tests__/__snapshots__/DownloadScreen.test.js.snap b/screens/__tests__/__snapshots__/DownloadScreen.test.js.snap index 5eaa7a2..8651e15 100644 --- a/screens/__tests__/__snapshots__/DownloadScreen.test.js.snap +++ b/screens/__tests__/__snapshots__/DownloadScreen.test.js.snap @@ -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", }, ] diff --git a/stores/__tests__/RootStore.test.js b/stores/__tests__/RootStore.test.js index c1e2160..af8f8a4 100644 --- a/stores/__tests__/RootStore.test.js +++ b/stores/__tests__/RootStore.test.js @@ -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);