diff --git a/__tests__/mainTest.js b/__tests__/mainTest.js index 1035039..8c8adf7 100644 --- a/__tests__/mainTest.js +++ b/__tests__/mainTest.js @@ -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 => { - expect(RNBackgroundDownloaderNative.initDownloader).toHaveBeenCalled() - expect(res).toBe(undefined) - }) + 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', () => { diff --git a/index.d.ts b/index.d.ts index 01336e2..944d5f8 100644 --- a/index.d.ts +++ b/index.d.ts @@ -79,7 +79,7 @@ export type EnsureDownloadsAreRunning = () => Promise; export interface InitDownloaderOptions { type?: 'parallel' | 'sequential' | null; } -export type InitDownloader = (options: InitDownloaderOptions) => Promise; +export type InitDownloader = (options: InitDownloaderOptions) => undefined; export interface DownloadOption { id: string; diff --git a/index.ts b/index.ts index 16caa92..e43292e 100644 --- a/index.ts +++ b/index.ts @@ -134,6 +134,7 @@ export const Priority = { } export default { + initDownloader, download, checkForExistingDownloads, ensureDownloadsAreRunning,