diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..fd4b23b --- /dev/null +++ b/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["react-native"] +} \ No newline at end of file diff --git a/__mocks__/RNBackgroundDownload.js b/__mocks__/RNBackgroundDownload.js new file mode 100644 index 0000000..96168d6 --- /dev/null +++ b/__mocks__/RNBackgroundDownload.js @@ -0,0 +1,6 @@ +import { NativeModules } from 'react-native'; + +NativeModules.RNBackgroundDownload = { + download: jest.fn(), + addListener: jest.fn() +}; \ No newline at end of file diff --git a/__tests__/mainTest.js b/__tests__/mainTest.js new file mode 100644 index 0000000..3115b49 --- /dev/null +++ b/__tests__/mainTest.js @@ -0,0 +1,10 @@ +import RNBackgroundDownload from '../index'; +import DownloadTask from '../lib/downloadTask'; + +test('download should return a downloadTask', () => { + expect(RNBackgroundDownload.download({ + id: 'test', + url: 'test', + destination: 'test' + })).toBeInstanceOf(DownloadTask); +}); \ No newline at end of file diff --git a/package.json b/package.json index 4233a13..0fdd0f7 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,10 @@ - { "name": "react-native-background-download", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "jest" }, "keywords": [ "react-native" @@ -14,5 +13,13 @@ "license": "", "peerDependencies": { "react-native": "^0.41.2" + }, + "devDependencies": { + "jest": "^23.1.0", + "react-native": "^0.55.4" + }, + "jest": { + "preset": "react-native", + "setupFiles": ["./__mocks__/RNBackgroundDownload.js"] } }