Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ajnart committed Dec 31, 2023
1 parent eba4dd3 commit a68f842
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
31 changes: 24 additions & 7 deletions src/widgets/torrent/TorrentTile.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('TorrentTile', () => {
displayActiveTorrents: true,
speedLimitOfActiveTorrents: 10,
displayStaleTorrents: false,
displayRatioWithFilter: false,
},
};
const torrents: NormalizedTorrent[] = [
Expand Down Expand Up @@ -60,6 +61,7 @@ describe('TorrentTile', () => {
displayActiveTorrents: true,
speedLimitOfActiveTorrents: 10,
displayStaleTorrents: true,
displayRatioWithFilter: false,
},
};
const torrents: NormalizedTorrent[] = [
Expand Down Expand Up @@ -97,6 +99,7 @@ describe('TorrentTile', () => {
displayActiveTorrents: false,
speedLimitOfActiveTorrents: 10,
displayStaleTorrents: true,
displayRatioWithFilter: false,
},
};
const torrents: NormalizedTorrent[] = [
Expand Down Expand Up @@ -134,12 +137,25 @@ describe('TorrentTile', () => {
displayActiveTorrents: true,
speedLimitOfActiveTorrents: 10,
displayStaleTorrents: true,
displayRatioWithFilter: false,
},
};
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 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),
];
Expand Down Expand Up @@ -175,6 +191,7 @@ describe('TorrentTile', () => {
displayActiveTorrents: true,
speedLimitOfActiveTorrents: 10,
displayStaleTorrents: true,
displayRatioWithFilter: false,
},
};
const torrents: NormalizedTorrent[] = [
Expand Down Expand Up @@ -212,6 +229,7 @@ describe('TorrentTile', () => {
displayActiveTorrents: false,
speedLimitOfActiveTorrents: 10,
displayStaleTorrents: true,
displayRatioWithFilter: false,
},
};
const torrents: NormalizedTorrent[] = [
Expand All @@ -229,7 +247,7 @@ describe('TorrentTile', () => {
expect(filtered.includes(torrents[1])).toBe(false);
expect(filtered.at(1)).toBe(torrents[2]);
});

it('calcul ratio', () => {
// arrange
const widget: ITorrent = {
Expand All @@ -249,11 +267,10 @@ describe('TorrentTile', () => {
displayActiveTorrents: false,
speedLimitOfActiveTorrents: 10,
displayStaleTorrents: true,
displayRatioWithFilter: false,
},
};
const torrents: NormalizedTorrent[] = [
constructTorrent('HH', 'I am completed', true, 0),
];
const torrents: NormalizedTorrent[] = [constructTorrent('HH', 'I am completed', true, 0, 0)];

// act
const filtered = filterTorrents(widget, torrents);
Expand All @@ -263,7 +280,7 @@ describe('TorrentTile', () => {
// assert
expect(filtered.length).toBe(0);
expect(filtered.includes(torrents[1])).toBe(false);
expect(ratioGlobal).toBe(378535535/23024335);
expect(ratioGlobal).toBe(378535535 / 23024335);
expect(ratioWithFilter).toBe(-1); //infinite ratio
});
});
Expand Down
4 changes: 4 additions & 0 deletions tests/pages/board/[slug].spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ vitest.mock('./../../tools/server/getServerSideTranslations.ts', () => ({
getServerSideTranslations: () => null,
}));

vitest.mock('../../../src/server/api/routers/docker/router.ts', () => ({
dockerRouter: () => null,
}));

describe('[slug] page', () => {
it('getServerSideProps should return not found when no params', async () => {
// arrange
Expand Down

0 comments on commit a68f842

Please sign in to comment.