Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(getConsoleIds): add iconUrl field #84

Merged
merged 1 commit into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}[];
Loading