Remove test from other PR
This commit is contained in:
@@ -20,15 +20,13 @@ describe('TorrentTile', () => {
|
|||||||
labelFilter: [],
|
labelFilter: [],
|
||||||
labelFilterIsWhitelist: false,
|
labelFilterIsWhitelist: false,
|
||||||
displayCompletedTorrents: true,
|
displayCompletedTorrents: true,
|
||||||
displayActiveTorrents: true,
|
|
||||||
speedLimitOfActiveTorrents: 10,
|
|
||||||
displayStaleTorrents: false,
|
displayStaleTorrents: false,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const torrents: NormalizedTorrent[] = [
|
const torrents: NormalizedTorrent[] = [
|
||||||
constructTorrent('ABC', 'Nice Torrent', false, 672, 672),
|
constructTorrent('ABC', 'Nice Torrent', false, 672),
|
||||||
constructTorrent('HH', 'I am completed', true, 0, 0),
|
constructTorrent('HH', 'I am completed', true, 0),
|
||||||
constructTorrent('HH', 'I am stale', false, 0, 0),
|
constructTorrent('HH', 'I am stale', false, 0),
|
||||||
];
|
];
|
||||||
|
|
||||||
// act
|
// act
|
||||||
@@ -57,15 +55,13 @@ describe('TorrentTile', () => {
|
|||||||
labelFilter: [],
|
labelFilter: [],
|
||||||
labelFilterIsWhitelist: false,
|
labelFilterIsWhitelist: false,
|
||||||
displayCompletedTorrents: true,
|
displayCompletedTorrents: true,
|
||||||
displayActiveTorrents: true,
|
|
||||||
speedLimitOfActiveTorrents: 10,
|
|
||||||
displayStaleTorrents: true,
|
displayStaleTorrents: true,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const torrents: NormalizedTorrent[] = [
|
const torrents: NormalizedTorrent[] = [
|
||||||
constructTorrent('ABC', 'Nice Torrent', false, 672, 672),
|
constructTorrent('ABC', 'Nice Torrent', false, 672),
|
||||||
constructTorrent('HH', 'I am completed', true, 0, 0),
|
constructTorrent('HH', 'I am completed', true, 0),
|
||||||
constructTorrent('HH', 'I am stale', false, 0, 0),
|
constructTorrent('HH', 'I am stale', false, 0),
|
||||||
];
|
];
|
||||||
|
|
||||||
// act
|
// act
|
||||||
@@ -78,7 +74,7 @@ describe('TorrentTile', () => {
|
|||||||
expect(filtered.includes(torrents[2])).toBe(true);
|
expect(filtered.includes(torrents[2])).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('filter when completed without active torrent', () => {
|
it('filter when completed', () => {
|
||||||
// arrange
|
// arrange
|
||||||
const widget: ITorrent = {
|
const widget: ITorrent = {
|
||||||
id: 'abc',
|
id: 'abc',
|
||||||
@@ -94,15 +90,13 @@ describe('TorrentTile', () => {
|
|||||||
labelFilter: [],
|
labelFilter: [],
|
||||||
labelFilterIsWhitelist: false,
|
labelFilterIsWhitelist: false,
|
||||||
displayCompletedTorrents: false,
|
displayCompletedTorrents: false,
|
||||||
displayActiveTorrents: false,
|
|
||||||
speedLimitOfActiveTorrents: 10,
|
|
||||||
displayStaleTorrents: true,
|
displayStaleTorrents: true,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const torrents: NormalizedTorrent[] = [
|
const torrents: NormalizedTorrent[] = [
|
||||||
constructTorrent('ABC', 'Nice Torrent', false, 672, 672),
|
constructTorrent('ABC', 'Nice Torrent', false, 672),
|
||||||
constructTorrent('HH', 'I am completed', true, 0, 672),
|
constructTorrent('HH', 'I am completed', true, 0),
|
||||||
constructTorrent('HH', 'I am stale', false, 0, 0),
|
constructTorrent('HH', 'I am stale', false, 0),
|
||||||
];
|
];
|
||||||
|
|
||||||
// act
|
// act
|
||||||
@@ -115,47 +109,6 @@ describe('TorrentTile', () => {
|
|||||||
expect(filtered.at(1)).toBe(torrents[2]);
|
expect(filtered.at(1)).toBe(torrents[2]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('filter when completed with active torrent', () => {
|
|
||||||
// arrange
|
|
||||||
const widget: ITorrent = {
|
|
||||||
id: 'abc',
|
|
||||||
area: {
|
|
||||||
type: 'sidebar',
|
|
||||||
properties: {
|
|
||||||
location: 'left',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
shape: {},
|
|
||||||
type: 'torrents-status',
|
|
||||||
properties: {
|
|
||||||
labelFilter: [],
|
|
||||||
labelFilterIsWhitelist: false,
|
|
||||||
displayCompletedTorrents: false,
|
|
||||||
displayActiveTorrents: true,
|
|
||||||
speedLimitOfActiveTorrents: 10,
|
|
||||||
displayStaleTorrents: true,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
const torrents: NormalizedTorrent[] = [
|
|
||||||
constructTorrent('ABC', 'Nice Torrent', false, 672, 672),
|
|
||||||
constructTorrent('HH', 'I am completed and uploading less than 10 ko/s (10239 ≈ 9.99ko/s)', true, 0, 10239),
|
|
||||||
constructTorrent('HH', 'I am completed and uploading more than 10 ko/s (10241 ≈ 10.01ko/s)', true, 0, 10241),
|
|
||||||
constructTorrent('HH', 'I am completed', true, 0, 0),
|
|
||||||
constructTorrent('HH', 'I am stale', false, 0, 0),
|
|
||||||
];
|
|
||||||
|
|
||||||
// act
|
|
||||||
const filtered = filterTorrents(widget, torrents);
|
|
||||||
|
|
||||||
// assert
|
|
||||||
expect(filtered.length).toBe(3);
|
|
||||||
expect(filtered.at(0)).toBe(torrents[0]);
|
|
||||||
expect(filtered.includes(torrents[1])).toBe(false);
|
|
||||||
expect(filtered.at(1)).toBe(torrents[2]);
|
|
||||||
expect(filtered.includes(torrents[3])).toBe(false);
|
|
||||||
expect(filtered.at(2)).toBe(torrents[4]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('filter by label when whitelist', () => {
|
it('filter by label when whitelist', () => {
|
||||||
// arrange
|
// arrange
|
||||||
const widget: ITorrent = {
|
const widget: ITorrent = {
|
||||||
@@ -172,15 +125,13 @@ describe('TorrentTile', () => {
|
|||||||
labelFilter: ['music', 'movie'],
|
labelFilter: ['music', 'movie'],
|
||||||
labelFilterIsWhitelist: true,
|
labelFilterIsWhitelist: true,
|
||||||
displayCompletedTorrents: true,
|
displayCompletedTorrents: true,
|
||||||
displayActiveTorrents: true,
|
|
||||||
speedLimitOfActiveTorrents: 10,
|
|
||||||
displayStaleTorrents: true,
|
displayStaleTorrents: true,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const torrents: NormalizedTorrent[] = [
|
const torrents: NormalizedTorrent[] = [
|
||||||
constructTorrent('1', 'A sick drop', false, 672, 672, 'music'),
|
constructTorrent('1', 'A sick drop', false, 672, 'music'),
|
||||||
constructTorrent('2', 'I cried', true, 0, 0, 'movie'),
|
constructTorrent('2', 'I cried', true, 0, 'movie'),
|
||||||
constructTorrent('3', 'Great Animations', false, 0, 0, 'anime'),
|
constructTorrent('3', 'Great Animations', false, 0, 'anime'),
|
||||||
];
|
];
|
||||||
|
|
||||||
// act
|
// act
|
||||||
@@ -209,15 +160,13 @@ describe('TorrentTile', () => {
|
|||||||
labelFilter: ['music', 'movie'],
|
labelFilter: ['music', 'movie'],
|
||||||
labelFilterIsWhitelist: false,
|
labelFilterIsWhitelist: false,
|
||||||
displayCompletedTorrents: false,
|
displayCompletedTorrents: false,
|
||||||
displayActiveTorrents: false,
|
|
||||||
speedLimitOfActiveTorrents: 10,
|
|
||||||
displayStaleTorrents: true,
|
displayStaleTorrents: true,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const torrents: NormalizedTorrent[] = [
|
const torrents: NormalizedTorrent[] = [
|
||||||
constructTorrent('ABC', 'Nice Torrent', false, 672, 672, 'anime'),
|
constructTorrent('ABC', 'Nice Torrent', false, 672, 'anime'),
|
||||||
constructTorrent('HH', 'I am completed', true, 0, 0, 'movie'),
|
constructTorrent('HH', 'I am completed', true, 0, 'movie'),
|
||||||
constructTorrent('HH', 'I am stale', false, 0, 0, 'tv'),
|
constructTorrent('HH', 'I am stale', false, 0, 'tv'),
|
||||||
];
|
];
|
||||||
|
|
||||||
// act
|
// act
|
||||||
@@ -229,8 +178,8 @@ describe('TorrentTile', () => {
|
|||||||
expect(filtered.includes(torrents[1])).toBe(false);
|
expect(filtered.includes(torrents[1])).toBe(false);
|
||||||
expect(filtered.at(1)).toBe(torrents[2]);
|
expect(filtered.at(1)).toBe(torrents[2]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('calcul ratio with and without torrent', () => {
|
it('calcul ratio', () => {
|
||||||
// arrange
|
// arrange
|
||||||
const widget: ITorrent = {
|
const widget: ITorrent = {
|
||||||
id: 'abc',
|
id: 'abc',
|
||||||
@@ -252,7 +201,7 @@ describe('TorrentTile', () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
const torrents: NormalizedTorrent[] = [
|
const torrents: NormalizedTorrent[] = [
|
||||||
constructTorrent('HH', 'I am completed', true, 0, 672),
|
constructTorrent('HH', 'I am completed', true, 0),
|
||||||
];
|
];
|
||||||
|
|
||||||
// act
|
// act
|
||||||
@@ -265,17 +214,14 @@ describe('TorrentTile', () => {
|
|||||||
expect(filtered.includes(torrents[1])).toBe(false);
|
expect(filtered.includes(torrents[1])).toBe(false);
|
||||||
expect(ratioGlobal).toBe(378535535/23024335);
|
expect(ratioGlobal).toBe(378535535/23024335);
|
||||||
expect(ratioWithFilter).toBe(-1); //infinite ratio
|
expect(ratioWithFilter).toBe(-1); //infinite ratio
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const constructTorrent = (
|
const constructTorrent = (
|
||||||
id: string,
|
id: string,
|
||||||
name: string,
|
name: string,
|
||||||
isCompleted: boolean,
|
isCompleted: boolean,
|
||||||
downloadSpeed: number, // Bytes per second in @ctrl/shared-torrent
|
downloadSpeed: number,
|
||||||
uploadSpeed: number, // Bytes per second in @ctrl/shared-torrent
|
|
||||||
label?: string
|
label?: string
|
||||||
): NormalizedTorrent => ({
|
): NormalizedTorrent => ({
|
||||||
id,
|
id,
|
||||||
@@ -299,6 +245,6 @@ const constructTorrent = (
|
|||||||
totalSize: 839539535,
|
totalSize: 839539535,
|
||||||
totalSelected: 0,
|
totalSelected: 0,
|
||||||
totalUploaded: 378535535,
|
totalUploaded: 378535535,
|
||||||
uploadSpeed,
|
uploadSpeed: 8349,
|
||||||
label,
|
label,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user