Skip to content

Commit

Permalink
Add electronic accessories management
Browse files Browse the repository at this point in the history
  • Loading branch information
dethstrobe committed Jan 18, 2021
1 parent 6500564 commit 5e64b17
Show file tree
Hide file tree
Showing 10 changed files with 20,978 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe("<Cyberdecks/>", () => {
expect(getTextInContainer(buyHeader, "Avail")).toBeInTheDocument()
expect(getTextInContainer(buyHeader, "Cost")).toBeInTheDocument()

// Stats of a commlink
// Stats of a cyberdeck
const cyberdeck = cyberdeckData[0],
cyberdeckRow = getByLabelText(`Add ${cyberdeck.name}`).closest("tr")

Expand Down
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()
})
})
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}
/>
)
Loading

0 comments on commit 5e64b17

Please sign in to comment.