Skip to content

Commit

Permalink
feat(getConsoleIds): add iconUrl field (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
wescopeland authored Mar 3, 2024
1 parent d9095bf commit 4a696c0
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 12 deletions.
50 changes: 41 additions & 9 deletions src/console/getConsoleIds.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { setupServer } from "msw/node";
import { apiBaseUrl } from "../utils/internal";
import { buildAuthorization } from "../utils/public";
import { getConsoleIds } from "./getConsoleIds";
import type { GetConsoleIdsResponse } from "./models";
import type { ConsoleId, GetConsoleIdsResponse } from "./models";

const server = setupServer();

Expand All @@ -29,9 +29,24 @@ describe("Function: getConsoleIds", () => {
});

const mockResponse: GetConsoleIdsResponse = [
{ ID: "1", Name: "Mega Drive" },
{ ID: "2", Name: "Nintendo 64" },
{ ID: "3", Name: "SNES" }
{
ID: "1",
Name: "Mega Drive",
IconURL:
"https://static.retroachievements.org/assets/images/system/md.png"
},
{
ID: "2",
Name: "Nintendo 64",
IconURL:
"https://static.retroachievements.org/assets/images/system/n64.png"
},
{
ID: "3",
Name: "SNES",
IconURL:
"https://static.retroachievements.org/assets/images/system/snes.png"
}
];

server.use(
Expand All @@ -44,10 +59,27 @@ describe("Function: getConsoleIds", () => {
const response = await getConsoleIds(authorization);

// ASSERT
expect(response).toEqual([
{ id: 1, name: "Mega Drive" },
{ id: 2, name: "Nintendo 64" },
{ id: 3, name: "SNES" }
]);
const expectedResponse: ConsoleId[] = [
{
id: 1,
name: "Mega Drive",
iconUrl:
"https://static.retroachievements.org/assets/images/system/md.png"
},
{
id: 2,
name: "Nintendo 64",
iconUrl:
"https://static.retroachievements.org/assets/images/system/n64.png"
},
{
id: 3,
name: "SNES",
iconUrl:
"https://static.retroachievements.org/assets/images/system/snes.png"
}
];

expect(response).toEqual(expectedResponse);
});
});
8 changes: 6 additions & 2 deletions src/console/getConsoleIds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ import type { ConsoleId, GetConsoleIdsResponse } from "./models";
*
* @returns An array containing a complete list of console ID
* and name pairs for RetroAchievements.org.
* ```
* { id: "1", name: "Mega Drive" }
* ```json
* {
* id: "1",
* name: "Mega Drive",
* iconUrl: "https://static.retroachievements.org/assets/images/system/md.png"
* }
* ```
*/
export const getConsoleIds = async (
Expand Down
1 change: 1 addition & 0 deletions src/console/models/console-id.model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export interface ConsoleId {
id: number;
name: string;
iconUrl: string;
}
6 changes: 5 additions & 1 deletion src/console/models/get-console-ids-response.model.ts
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
export type GetConsoleIdsResponse = readonly { ID: string; Name: string }[];
export type GetConsoleIdsResponse = readonly {
ID: string;
Name: string;
IconURL: string;
}[];

0 comments on commit 4a696c0

Please sign in to comment.