Skip to content

Commit b72ff8e

Browse files
committed
chore: add more tests
1 parent b7de668 commit b72ff8e

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

test/index.spec.ts

+22-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import fs from 'fs';
55
import { Deluge } from '../src/index';
66

77
const baseUrl = 'http://localhost:8112';
8+
const torrentName = 'ubuntu-18.04.1-desktop-amd64.iso';
89
const torrentFile = path.join(__dirname, '/ubuntu-18.04.1-desktop-amd64.iso.torrent');
910

1011
async function setupTorrent(deluge: Deluge) {
@@ -44,7 +45,6 @@ describe('Deluge', () => {
4445
it('should connect', async () => {
4546
const deluge = new Deluge({ baseUrl });
4647
const res = await deluge.connect();
47-
// tslint:disable-next-line:no-null-keyword
4848
expect(res.result).toBe(null);
4949
});
5050
it('should get plugins', async () => {
@@ -97,7 +97,7 @@ describe('Deluge', () => {
9797
});
9898
it('should logout', async () => {
9999
const deluge = new Deluge({ baseUrl });
100-
await deluge.login();
100+
await deluge.logout();
101101
const success = await deluge.logout();
102102
expect(success).toBe(true);
103103
});
@@ -152,7 +152,7 @@ describe('Deluge', () => {
152152
const keys = Object.keys(res.result.torrents);
153153
for (const key of keys) {
154154
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);
156156
}
157157
});
158158
it('should list torrents', async () => {
@@ -167,6 +167,25 @@ describe('Deluge', () => {
167167
expect(torrent.is_auto_managed).toBe(true);
168168
}
169169
});
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+
});
170189
it('should move torrents in queue', async () => {
171190
const deluge = new Deluge({ baseUrl });
172191
const res = await setupTorrent(deluge);

0 commit comments

Comments
 (0)