fix export initDownloader & tests

This commit is contained in:
Kesha Antonov
2023-07-17 14:13:22 +03:00
parent 1c22e0602e
commit e4a7730c81
3 changed files with 14 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
import RNBackgroundDownloader, { initDownloader } from '../index'
import RNBackgroundDownloader from '../index'
import DownloadTask from '../lib/downloadTask'
import { NativeModules, NativeEventEmitter } from 'react-native'
@@ -130,11 +130,17 @@ test('stop', () => {
})
test('initDownloader', () => {
return RNBackgroundDownloader.initDownloader()
.then(res => {
jest.mock('react-native/Libraries/Utilities/Platform', () => {
const Platform = jest.requireActual(
'react-native/Libraries/Utilities/Platform'
)
Platform.OS = 'android'
return Platform
})
const res = RNBackgroundDownloader.initDownloader()
expect(RNBackgroundDownloaderNative.initDownloader).toHaveBeenCalled()
expect(res).toBe(undefined)
})
})
test('checkForExistingDownloads', () => {

2
index.d.ts vendored
View File

@@ -79,7 +79,7 @@ export type EnsureDownloadsAreRunning = () => Promise<void>;
export interface InitDownloaderOptions {
type?: 'parallel' | 'sequential' | null;
}
export type InitDownloader = (options: InitDownloaderOptions) => Promise<void>;
export type InitDownloader = (options: InitDownloaderOptions) => undefined;
export interface DownloadOption {
id: string;

View File

@@ -134,6 +134,7 @@ export const Priority = {
}
export default {
initDownloader,
download,
checkForExistingDownloads,
ensureDownloadsAreRunning,