-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b449ab
commit 7a31ae5
Showing
10 changed files
with
217 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
describe("Connect Wallet Modal Open Test", () => { | ||
beforeEach(() => { | ||
cy.visit("http://localhost:3001"); | ||
}); | ||
|
||
it("open Connect Wallet Modal", () => { | ||
cy.get('[class*="connected_wallet"]').should("exist"); | ||
cy.get('[class*="connected_wallet"]').click(); | ||
cy.wait(10000); | ||
cy.get('[class*="connect-wallet-outer-container"]').should("exist"); | ||
}); | ||
}); |
Empty file.
78 changes: 78 additions & 0 deletions
78
...erboard/src/app/components/ConnectWallet/ConnectedWalletModal/connectedWalletModal.cy.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { ConnectedWalletModal } from "./ConnectedWalletModal"; | ||
import React from "react"; | ||
|
||
const addressSize = 12 / 2; | ||
const trimAddress = (address: string) => { | ||
const leftSide = address.substring(0, addressSize); | ||
|
||
const rightSide = address.substring( | ||
address.length - addressSize, | ||
address.length | ||
); | ||
|
||
return `${leftSide}..${rightSide}`; | ||
}; | ||
|
||
describe("ConnectedWalletModal Component Tests", () => { | ||
it("Renders the modal when visible is true", () => { | ||
const props = { | ||
visible: true, | ||
address: "0x0x3a568E31540E2179b4833b21C6a45710b569D595", | ||
close: cy.stub().as("close"), | ||
disconnect: cy.stub().as("disconnect"), | ||
}; | ||
|
||
cy.mount(<ConnectedWalletModal {...props} />); | ||
cy.get('[class*="show-modal"]').should("exist"); | ||
}); | ||
|
||
it("Does not render the modal when visible is false", () => { | ||
const props = { | ||
visible: false, | ||
address: "0x0x3a568E31540E2179b4833b21C6a45710b569D595", | ||
close: cy.stub().as("close"), | ||
disconnect: cy.stub().as("disconnect"), | ||
}; | ||
|
||
cy.mount(<ConnectedWalletModal {...props} />); | ||
|
||
cy.get('[class*="show-modal"]').should("not.exist"); | ||
}); | ||
|
||
it("Displays the address correctly", () => { | ||
const props = { | ||
visible: true, | ||
address: "0x0x3a568E31540E2179b4833b21C6a45710b569D595", | ||
close: cy.stub().as("close"), | ||
disconnect: cy.stub().as("disconnect"), | ||
}; | ||
cy.mount(<ConnectedWalletModal {...props} />); | ||
cy.contains(trimAddress(props.address)).should("be.visible"); | ||
}); | ||
|
||
it("Calls the disconnect function on disconnect button click", () => { | ||
const props = { | ||
visible: true, | ||
address: "0x0x3a568E31540E2179b4833b21C6a45710b569D595", | ||
close: cy.stub().as("close"), | ||
disconnect: cy.stub().as("disconnect"), | ||
}; | ||
|
||
cy.mount(<ConnectedWalletModal {...props} />); | ||
cy.get('[class*="disconnect-wallet-btn-in-modal"]').click(); | ||
cy.get("@disconnect").should("have.been.calledOnce"); | ||
}); | ||
|
||
it("Calls the close function on close (cross) button click", () => { | ||
const props = { | ||
visible: true, | ||
address: "0x0x3a568E31540E2179b4833b21C6a45710b569D595", | ||
close: cy.stub().as("close"), | ||
disconnect: cy.stub().as("disconnect"), | ||
}; | ||
|
||
cy.mount(<ConnectedWalletModal {...props} />); | ||
cy.get('[class*="modal-cancel-btn"]').click(); | ||
cy.get("@close").should("have.been.calledOnce"); | ||
}); | ||
}); |
44 changes: 44 additions & 0 deletions
44
web/leaderboard/src/app/components/Dropdown/dropdown.cy.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React from "react"; | ||
import { DropdownOptions } from "./index"; | ||
import "@fluidity-money/surfing"; | ||
import "./Dropdown.module.scss"; | ||
|
||
describe("DropdownOptions Component", () => { | ||
let setSortedByItem: any; | ||
let setOpenDropdown: any; | ||
let sortData: any; | ||
|
||
beforeEach(() => { | ||
setSortedByItem = cy.stub(); | ||
setOpenDropdown = cy.stub(); | ||
sortData = cy.stub(); | ||
|
||
cy.mount( | ||
<DropdownOptions | ||
setSortedByItem={setSortedByItem} | ||
setOpenDropdown={setOpenDropdown} | ||
sortData={sortData} | ||
/> | ||
); | ||
}); | ||
|
||
it("renders correctly", () => { | ||
cy.get("[class*='dropdown_options']").should("exist"); | ||
cy.get("[class*='dropdown_options'] ul li").should("have.length", 3); | ||
}); | ||
|
||
it("handles option click correctly", () => { | ||
const optionTitles = ["volume", "rewards", "number"]; | ||
|
||
optionTitles.forEach((title, index) => { | ||
cy.get("[class*='dropdown_options'] ul li") | ||
.eq(index) | ||
.click() | ||
.then(() => { | ||
expect(setSortedByItem).to.be.calledWith(optionTitles[index]); | ||
expect(setOpenDropdown).to.be.calledWith(false); | ||
expect(sortData).to.be.calledWith(optionTitles[index].toLowerCase()); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import React from "react"; | ||
import Footer from "./index"; | ||
|
||
describe("<Footer />", () => { | ||
it("mounts <Footer />", () => { | ||
cy.mount(<Footer />); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import React from "react"; | ||
import { Profile } from "./index"; | ||
|
||
describe("<Profile />", () => { | ||
it("mounts <Profile />", () => { | ||
cy.mount(<Profile />); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import type { NextApiRequest, NextApiResponse } from "next"; | ||
|
||
type User = { | ||
address: string; | ||
number_of_transactions: number; | ||
rank: number; | ||
volume: number; | ||
yield_earned: number; | ||
}; | ||
|
||
export default function users( | ||
req: NextApiRequest, | ||
res: NextApiResponse<User[]> | ||
) { | ||
res.statusCode = 200; | ||
res.setHeader("Content-Type", "application/json"); | ||
return res.json([ | ||
{ | ||
address: "0x21f2275f26611fba1d486153b5d2d78164568435", | ||
number_of_transactions: 21898, | ||
rank: 2388, | ||
volume: 255.13345799999914, | ||
yield_earned: 18.985949367059586, | ||
}, | ||
{ | ||
address: "0x1cb94adfd3314d48ca8145b2c6983419257c0486", | ||
number_of_transactions: 12520, | ||
rank: 3682, | ||
volume: 894699.873285003, | ||
yield_earned: 482.0982366909158, | ||
}, | ||
{ | ||
address: "0xe776ffdab7b40147fc0b8e93676eb444fb3650b6", | ||
number_of_transactions: 7135, | ||
rank: 4260, | ||
volume: 240194.4372060101, | ||
yield_earned: 920.81961067, | ||
}, | ||
]); | ||
} |