@@ -10,27 +10,27 @@ jest.mock('NativeEventEmitter', () => {
10
10
} ;
11
11
} ) ;
12
12
13
- import RNBackgroundDownload from '../index' ;
13
+ import RNBackgroundDownloader from '../index' ;
14
14
import DownloadTask from '../lib/downloadTask' ;
15
15
import { NativeEventEmitter , NativeModules } from 'react-native' ;
16
16
17
- const RNBackgroundDownloadNative = NativeModules . RNBackgroundDownload ;
17
+ const RNBackgroundDownloaderNative = NativeModules . RNBackgroundDownloader ;
18
18
19
19
let downloadTask ;
20
20
21
21
test ( 'download function' , ( ) => {
22
- downloadTask = RNBackgroundDownload . download ( {
22
+ downloadTask = RNBackgroundDownloader . download ( {
23
23
id : 'test' ,
24
24
url : 'test' ,
25
25
destination : 'test'
26
26
} ) ;
27
27
expect ( downloadTask ) . toBeInstanceOf ( DownloadTask ) ;
28
- expect ( RNBackgroundDownloadNative . download ) . toHaveBeenCalled ( ) ;
28
+ expect ( RNBackgroundDownloaderNative . download ) . toHaveBeenCalled ( ) ;
29
29
} ) ;
30
30
31
31
test ( 'begin event' , ( ) => {
32
32
return new Promise ( resolve => {
33
- const beginDT = RNBackgroundDownload . download ( {
33
+ const beginDT = RNBackgroundDownloader . download ( {
34
34
id : 'testBegin' ,
35
35
url : 'test' ,
36
36
destination : 'test'
@@ -48,7 +48,7 @@ test('begin event', () => {
48
48
49
49
test ( 'progress event' , ( ) => {
50
50
return new Promise ( resolve => {
51
- RNBackgroundDownload . download ( {
51
+ RNBackgroundDownloader . download ( {
52
52
id : 'testProgress' ,
53
53
url : 'test' ,
54
54
destination : 'test'
@@ -69,7 +69,7 @@ test('progress event', () => {
69
69
70
70
test ( 'done event' , ( ) => {
71
71
return new Promise ( resolve => {
72
- const doneDT = RNBackgroundDownload . download ( {
72
+ const doneDT = RNBackgroundDownloader . download ( {
73
73
id : 'testDone' ,
74
74
url : 'test' ,
75
75
destination : 'test'
@@ -85,7 +85,7 @@ test('done event', () => {
85
85
86
86
test ( 'fail event' , ( ) => {
87
87
return new Promise ( resolve => {
88
- const failDT = RNBackgroundDownload . download ( {
88
+ const failDT = RNBackgroundDownloader . download ( {
89
89
id : 'testFail' ,
90
90
url : 'test' ,
91
91
destination : 'test'
@@ -102,45 +102,45 @@ test('fail event', () => {
102
102
} ) ;
103
103
104
104
test ( 'pause' , ( ) => {
105
- const pauseDT = RNBackgroundDownload . download ( {
105
+ const pauseDT = RNBackgroundDownloader . download ( {
106
106
id : 'testPause' ,
107
107
url : 'test' ,
108
108
destination : 'test'
109
109
} ) ;
110
110
111
111
pauseDT . pause ( ) ;
112
112
expect ( pauseDT . state ) . toBe ( 'PAUSED' ) ;
113
- expect ( RNBackgroundDownloadNative . pauseTask ) . toHaveBeenCalled ( ) ;
113
+ expect ( RNBackgroundDownloaderNative . pauseTask ) . toHaveBeenCalled ( ) ;
114
114
} ) ;
115
115
116
116
test ( 'resume' , ( ) => {
117
- const resumeDT = RNBackgroundDownload . download ( {
117
+ const resumeDT = RNBackgroundDownloader . download ( {
118
118
id : 'testResume' ,
119
119
url : 'test' ,
120
120
destination : 'test'
121
121
} ) ;
122
122
123
123
resumeDT . resume ( ) ;
124
124
expect ( resumeDT . state ) . toBe ( 'DOWNLOADING' ) ;
125
- expect ( RNBackgroundDownloadNative . resumeTask ) . toHaveBeenCalled ( ) ;
125
+ expect ( RNBackgroundDownloaderNative . resumeTask ) . toHaveBeenCalled ( ) ;
126
126
} ) ;
127
127
128
128
test ( 'stop' , ( ) => {
129
- const stopDT = RNBackgroundDownload . download ( {
129
+ const stopDT = RNBackgroundDownloader . download ( {
130
130
id : 'testStop' ,
131
131
url : 'test' ,
132
132
destination : 'test'
133
133
} ) ;
134
134
135
135
stopDT . stop ( ) ;
136
136
expect ( stopDT . state ) . toBe ( 'STOPPED' ) ;
137
- expect ( RNBackgroundDownloadNative . stopTask ) . toHaveBeenCalled ( ) ;
137
+ expect ( RNBackgroundDownloaderNative . stopTask ) . toHaveBeenCalled ( ) ;
138
138
} ) ;
139
139
140
140
test ( 'checkForExistingDownloads' , ( ) => {
141
- return RNBackgroundDownload . checkForExistingDownloads ( )
141
+ return RNBackgroundDownloader . checkForExistingDownloads ( )
142
142
. then ( foundDownloads => {
143
- expect ( RNBackgroundDownloadNative . checkForExistingDownloads ) . toHaveBeenCalled ( ) ;
143
+ expect ( RNBackgroundDownloaderNative . checkForExistingDownloads ) . toHaveBeenCalled ( ) ;
144
144
expect ( foundDownloads . length ) . toBe ( 4 ) ;
145
145
foundDownloads . forEach ( foundDownload => {
146
146
expect ( foundDownload ) . toBeInstanceOf ( DownloadTask ) ;
@@ -151,7 +151,7 @@ test('checkForExistingDownloads', () => {
151
151
} ) ;
152
152
153
153
test ( 'wrong handler type' , ( ) => {
154
- let dt = RNBackgroundDownload . download ( {
154
+ let dt = RNBackgroundDownloader . download ( {
155
155
id : 'test22222' ,
156
156
url : 'test' ,
157
157
destination : 'test'
0 commit comments