mirror of
https://github.com/zoriya/react-native-background-downloader.git
synced 2025-12-06 06:56:10 +00:00
fix export initDownloader & tests
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import RNBackgroundDownloader, { initDownloader } from '../index'
|
import RNBackgroundDownloader from '../index'
|
||||||
import DownloadTask from '../lib/downloadTask'
|
import DownloadTask from '../lib/downloadTask'
|
||||||
import { NativeModules, NativeEventEmitter } from 'react-native'
|
import { NativeModules, NativeEventEmitter } from 'react-native'
|
||||||
|
|
||||||
@@ -130,11 +130,17 @@ test('stop', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('initDownloader', () => {
|
test('initDownloader', () => {
|
||||||
return RNBackgroundDownloader.initDownloader()
|
jest.mock('react-native/Libraries/Utilities/Platform', () => {
|
||||||
.then(res => {
|
const Platform = jest.requireActual(
|
||||||
|
'react-native/Libraries/Utilities/Platform'
|
||||||
|
)
|
||||||
|
Platform.OS = 'android'
|
||||||
|
return Platform
|
||||||
|
})
|
||||||
|
|
||||||
|
const res = RNBackgroundDownloader.initDownloader()
|
||||||
expect(RNBackgroundDownloaderNative.initDownloader).toHaveBeenCalled()
|
expect(RNBackgroundDownloaderNative.initDownloader).toHaveBeenCalled()
|
||||||
expect(res).toBe(undefined)
|
expect(res).toBe(undefined)
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
test('checkForExistingDownloads', () => {
|
test('checkForExistingDownloads', () => {
|
||||||
|
|||||||
2
index.d.ts
vendored
2
index.d.ts
vendored
@@ -79,7 +79,7 @@ export type EnsureDownloadsAreRunning = () => Promise<void>;
|
|||||||
export interface InitDownloaderOptions {
|
export interface InitDownloaderOptions {
|
||||||
type?: 'parallel' | 'sequential' | null;
|
type?: 'parallel' | 'sequential' | null;
|
||||||
}
|
}
|
||||||
export type InitDownloader = (options: InitDownloaderOptions) => Promise<void>;
|
export type InitDownloader = (options: InitDownloaderOptions) => undefined;
|
||||||
|
|
||||||
export interface DownloadOption {
|
export interface DownloadOption {
|
||||||
id: string;
|
id: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user