-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add electronic accessories management
- Loading branch information
1 parent
6500564
commit 5e64b17
Showing
10 changed files
with
20,978 additions
and
23 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
36 changes: 36 additions & 0 deletions
36
components/runner/resources/electronics/ElectronicAccessories/ElectronicAccessories.test.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,36 @@ | ||
import { electronicAccessoriesData } from "@/data/electronics" | ||
import { | ||
render, | ||
setupIndexedDB, | ||
waitFor, | ||
withTestRouter, | ||
getByText as getTextInContainer, | ||
} from "@/test/testUtils" | ||
import ElectronicAccessories from "./index" | ||
|
||
describe("<ElectronicAccessories/>", () => { | ||
beforeAll(setupIndexedDB) | ||
it("should display Electronic Accessories' stats", async () => { | ||
const { getByText, getByLabelText } = render( | ||
withTestRouter(<ElectronicAccessories />, { query: { id: "10" } }), | ||
) | ||
|
||
await waitFor(() => expect(getByText("Buy")).toBeInTheDocument()) | ||
|
||
const buyHeader = getByText("Buy").closest("tr") | ||
|
||
expect(getTextInContainer(buyHeader, "Name")).toBeInTheDocument() | ||
expect(getTextInContainer(buyHeader, "DR")).toBeInTheDocument() | ||
expect(getTextInContainer(buyHeader, "Avail")).toBeInTheDocument() | ||
expect(getTextInContainer(buyHeader, "Cost")).toBeInTheDocument() | ||
|
||
//stats | ||
const eA = electronicAccessoriesData[0], | ||
eARow = getByLabelText(`Add ${eA.name}`).closest("tr") | ||
|
||
expect(getTextInContainer(eARow, eA.name)).toBeInTheDocument() | ||
expect(getTextInContainer(eARow, eA.deviceRating)).toBeInTheDocument() | ||
expect(getTextInContainer(eARow, eA.availability)).toBeInTheDocument() | ||
expect(getTextInContainer(eARow, `${eA.cost}¥`)).toBeInTheDocument() | ||
}) | ||
}) |
27 changes: 27 additions & 0 deletions
27
components/runner/resources/electronics/ElectronicAccessories/index.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,27 @@ | ||
import { electronicAccessoriesData } from "@/data/electronics" | ||
import { GearElectronicAccessory } from "@/types/Resources" | ||
import { GearPageTemplate } from "../../GearPageTemplate" | ||
import { Columns, gearTableConfigOptions } from "../../util" | ||
import { gearMatrixTableConfigOptions } from "../utils" | ||
|
||
type eACols = Columns<GearElectronicAccessory>[] | ||
|
||
const baseCols: eACols = [ | ||
gearTableConfigOptions.name, | ||
gearMatrixTableConfigOptions.deviceRating, | ||
gearTableConfigOptions.avail, | ||
gearTableConfigOptions.cost, | ||
] | ||
|
||
const buyEACol: eACols = [gearTableConfigOptions.buy, ...baseCols] | ||
const sellEACol: eACols = [gearTableConfigOptions.sell, ...baseCols] | ||
|
||
export default () => ( | ||
<GearPageTemplate<GearElectronicAccessory> | ||
gearLabel="Electronic Accessories" | ||
resourceKey="electronicAccessories" | ||
listOfGear={electronicAccessoriesData} | ||
addGearTableConfig={buyEACol} | ||
removeGearTableConfig={sellEACol} | ||
/> | ||
) |
Oops, something went wrong.