@@ -5,6 +5,7 @@ import fs from 'fs';
5
5
import { Deluge } from '../src/index' ;
6
6
7
7
const baseUrl = 'http://localhost:8112' ;
8
+ const torrentName = 'ubuntu-18.04.1-desktop-amd64.iso' ;
8
9
const torrentFile = path . join ( __dirname , '/ubuntu-18.04.1-desktop-amd64.iso.torrent' ) ;
9
10
10
11
async function setupTorrent ( deluge : Deluge ) {
@@ -44,7 +45,6 @@ describe('Deluge', () => {
44
45
it ( 'should connect' , async ( ) => {
45
46
const deluge = new Deluge ( { baseUrl } ) ;
46
47
const res = await deluge . connect ( ) ;
47
- // tslint:disable-next-line:no-null-keyword
48
48
expect ( res . result ) . toBe ( null ) ;
49
49
} ) ;
50
50
it ( 'should get plugins' , async ( ) => {
@@ -97,7 +97,7 @@ describe('Deluge', () => {
97
97
} ) ;
98
98
it ( 'should logout' , async ( ) => {
99
99
const deluge = new Deluge ( { baseUrl } ) ;
100
- await deluge . login ( ) ;
100
+ await deluge . logout ( ) ;
101
101
const success = await deluge . logout ( ) ;
102
102
expect ( success ) . toBe ( true ) ;
103
103
} ) ;
@@ -152,7 +152,7 @@ describe('Deluge', () => {
152
152
const keys = Object . keys ( res . result . torrents ) ;
153
153
for ( const key of keys ) {
154
154
const status = await deluge . getTorrentStatus ( key ) ;
155
- expect ( status . result . name ) . toEqual ( 'ubuntu-18.04.1-desktop-amd64.iso' ) ;
155
+ expect ( status . result . name ) . toEqual ( torrentName ) ;
156
156
}
157
157
} ) ;
158
158
it ( 'should list torrents' , async ( ) => {
@@ -167,6 +167,25 @@ describe('Deluge', () => {
167
167
expect ( torrent . is_auto_managed ) . toBe ( true ) ;
168
168
}
169
169
} ) ;
170
+ it ( 'should get array of normalized torrent data' , async ( ) => {
171
+ const deluge = new Deluge ( { baseUrl } ) ;
172
+ await setupTorrent ( deluge ) ;
173
+ const res = await deluge . getAllData ( ) ;
174
+ expect ( res . torrents ) . toHaveLength ( 1 ) ;
175
+ for ( const torrent of res . torrents ) {
176
+ expect ( torrent . id ) . toBeDefined ( ) ;
177
+ expect ( torrent . name ) . toBe ( torrentName ) ;
178
+ }
179
+ } ) ;
180
+ it ( 'should get normalized torrent data' , async ( ) => {
181
+ const deluge = new Deluge ( { baseUrl } ) ;
182
+ const res = await setupTorrent ( deluge ) ;
183
+ const keys = Object . keys ( res . result . torrents ) ;
184
+ for ( const key of keys ) {
185
+ const torrent = await deluge . getTorrent ( key ) ;
186
+ expect ( torrent . name ) . toEqual ( torrentName ) ;
187
+ }
188
+ } ) ;
170
189
it ( 'should move torrents in queue' , async ( ) => {
171
190
const deluge = new Deluge ( { baseUrl } ) ;
172
191
const res = await setupTorrent ( deluge ) ;
0 commit comments