refactor(mock): convert mock ids to numeric strings
This commit is contained in:
@@ -16,33 +16,32 @@ describe("searchCatalog", () => {
|
||||
it("matches player nickname", () => {
|
||||
const res = searchCatalog({ q: "winter", limit: 50 }, data)
|
||||
const playerItems = res.items.filter((i) => i.type === "player")
|
||||
expect(playerItems.some((i) => i.type === "player" && i.player.id === "u6")).toBe(true)
|
||||
expect(playerItems.some((i) => i.type === "player" && i.player.id === "1006")).toBe(true)
|
||||
})
|
||||
|
||||
it("matches player nickname case-insensitively", () => {
|
||||
const res = searchCatalog({ q: "WINTER", limit: 50 }, data)
|
||||
const playerItems = res.items.filter((i) => i.type === "player")
|
||||
expect(playerItems.some((i) => i.type === "player" && i.player.id === "u6")).toBe(true)
|
||||
expect(playerItems.some((i) => i.type === "player" && i.player.id === "1006")).toBe(true)
|
||||
})
|
||||
|
||||
it("matches shop name", () => {
|
||||
const res = searchCatalog({ q: "yuki", limit: 50 }, data)
|
||||
const shopItems = res.items.filter((i) => i.type === "shop")
|
||||
expect(shopItems.some((i) => i.type === "shop" && i.shop.id === "shop2")).toBe(true)
|
||||
expect(shopItems.some((i) => i.type === "shop" && i.shop.id === "3002")).toBe(true)
|
||||
})
|
||||
|
||||
it("matches player game name", () => {
|
||||
const res = searchCatalog({ q: "cs2", limit: 50 }, data)
|
||||
const playerItems = res.items.filter((i) => i.type === "player")
|
||||
// u8 has CS2 in games
|
||||
expect(playerItems.some((i) => i.type === "player" && i.player.id === "u8")).toBe(true)
|
||||
// 1008 has CS2 in games
|
||||
expect(playerItems.some((i) => i.type === "player" && i.player.id === "1008")).toBe(true)
|
||||
})
|
||||
|
||||
it("matches shop derived games", () => {
|
||||
const res = searchCatalog({ q: "cs2", limit: 50 }, data)
|
||||
const shopItems = res.items.filter((i) => i.type === "shop")
|
||||
// shop1 has CS2 via u5's service s3
|
||||
expect(shopItems.some((i) => i.type === "shop" && i.shop.id === "shop1")).toBe(true)
|
||||
expect(shopItems.some((i) => i.type === "shop" && i.shop.id === "3001")).toBe(true)
|
||||
})
|
||||
|
||||
it("returns all items when q is empty", () => {
|
||||
@@ -64,8 +63,7 @@ describe("searchCatalog", () => {
|
||||
it("filters shops by derived games from services", () => {
|
||||
const res = searchCatalog({ selectedGames: ["CS2"], limit: 50 }, data)
|
||||
const shopItems = res.items.filter((i) => i.type === "shop")
|
||||
// shop1 has CS2 via services
|
||||
expect(shopItems.some((i) => i.type === "shop" && i.shop.id === "shop1")).toBe(true)
|
||||
expect(shopItems.some((i) => i.type === "shop" && i.shop.id === "3001")).toBe(true)
|
||||
})
|
||||
|
||||
it("uses ANY-match (OR) for multiple games", () => {
|
||||
@@ -93,8 +91,8 @@ describe("searchCatalog", () => {
|
||||
}
|
||||
}
|
||||
// u7 is busy, u9 is offline — they should be excluded
|
||||
expect(playerItems.some((i) => i.type === "player" && i.player.id === "u7")).toBe(false)
|
||||
expect(playerItems.some((i) => i.type === "player" && i.player.id === "u9")).toBe(false)
|
||||
expect(playerItems.some((i) => i.type === "player" && i.player.id === "1007")).toBe(false)
|
||||
expect(playerItems.some((i) => i.type === "player" && i.player.id === "1009")).toBe(false)
|
||||
})
|
||||
|
||||
it("filters shops by hasAvailable (any player available)", () => {
|
||||
@@ -105,10 +103,8 @@ describe("searchCatalog", () => {
|
||||
expect(item.hasAvailable).toBe(true)
|
||||
}
|
||||
}
|
||||
// shop3 has only u9 (offline) → excluded
|
||||
expect(shopItems.some((i) => i.type === "shop" && i.shop.id === "shop3")).toBe(false)
|
||||
// shop1 has u5 (available) → included
|
||||
expect(shopItems.some((i) => i.type === "shop" && i.shop.id === "shop1")).toBe(true)
|
||||
expect(shopItems.some((i) => i.type === "shop" && i.shop.id === "3003")).toBe(false)
|
||||
expect(shopItems.some((i) => i.type === "shop" && i.shop.id === "3001")).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user