Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(table): add unit test for ratio #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test(table): add unit test for ratio
  • Loading branch information
zj9495 committed Jun 13, 2021
commit 45b3c35def5eb75f79e4c05b1383a944408e6697
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"react-hook-form": "^6.14.1",
"react-intl": "^5.10.6",
"react-redux": "^7.2.2",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.2",
"redux": "^4.0.5",
Expand Down
84 changes: 84 additions & 0 deletions src/components/TorrentTable/index.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import React from "react";
import routeData from "react-router";

import renderWithProviders from "src/components/renderWithProviders";

import TorrentTable from "./index";

describe("renders TorrentTable", () => {
describe("test format ratio", () => {
jest.spyOn(routeData, "useParams").mockReturnValue({
torrentStatus: "all",
});
const state = {
rpc: {
torrents: {
all: [
{
activityDate: 0,
addedDate: 1618543449,
doneDate: 0,
downloadDir: "/downloads/complete",
downloadedEver: 0,
error: 0,
errorString: "",
hashString: "d3d0774b8d3d1389a956899250de94d5f11b29be",
id: 60,
leftUntilDone: 257751467,
name:
"Beethoven - Piano Trio in C minor, Triple Concerto [Oborin, Oistrakh, Knushevitskiy] (2011) [FLAC]",
peersGettingFromUs: 0,
peersSendingToUs: 0,
percentDone: 0,
queuePosition: 0,
rateDownload: 0,
rateUpload: 0,
recheckProgress: 0,
status: 0,
totalSize: 257751467,
trackerStats: [
{
announce:
"http://www.hdarea.co/announce.php?passkey=ddeb644cd5dac0c3c3b00152e415fdf8",
announceState: 0,
downloadCount: 25,
hasAnnounced: false,
hasScraped: true,
host: "http://www.hdarea.co:80",
id: 0,
isBackup: false,
lastAnnouncePeerCount: 0,
lastAnnounceResult: "",
lastAnnounceStartTime: 0,
lastAnnounceSucceeded: false,
lastAnnounceTime: 0,
lastAnnounceTimedOut: false,
lastScrapeResult: "",
lastScrapeStartTime: 1618550740,
lastScrapeSucceeded: true,
lastScrapeTime: 1618550741,
lastScrapeTimedOut: false,
leecherCount: 0,
nextAnnounceTime: 0,
nextScrapeTime: 1618552550,
scrape:
"http://www.hdarea.co/scrape.php?passkey=ddeb644cd5dac0c3c3b00152e415fdf8",
scrapeState: 1,
seederCount: 8,
tier: 0,
},
],
uploadRatio: -1,
uploadedEver: 0,
},
],
},
},
};
const { container } = renderWithProviders(<TorrentTable />, state);
expect(
container.querySelector("[data-field='uploadRatio'][data-rowindex='0']")
?.textContent
).toBe("0");
});
});
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11405,10 +11405,10 @@ react-router-dom@^5.2.0:
tiny-invariant "^1.0.2"
tiny-warning "^1.0.0"

react-router@5.2.0:
react-router@5.2.0, react-router@^5.2.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/react-router/-/react-router-5.2.0.tgz#424e75641ca8747fbf76e5ecca69781aa37ea293"
integrity sha512-smz1DUuFHRKdcJC0jobGo8cVbhO3x50tCL4icacOlcwDOEQPq4TMqwx3sY1TP+DvtTgz4nm3thuo7A+BK2U0Dw==
resolved "https://registry.npm.taobao.org/react-router/download/react-router-5.2.0.tgz#424e75641ca8747fbf76e5ecca69781aa37ea293"
integrity sha1-Qk51ZByodH+/duXsyml4GqN+opM=
dependencies:
"@babel/runtime" "^7.1.2"
history "^4.9.0"
Expand Down