{"id":25938631,"url":"https://github.com/michaeljscript/deck-game","last_synced_at":"2025-03-04T03:37:45.590Z","repository":{"id":87448294,"uuid":"376610508","full_name":"michaeljscript/deck-game","owner":"michaeljscript","description":"Deck Game","archived":false,"fork":false,"pushed_at":"2021-06-13T18:14:58.000Z","size":241,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-01-28T18:20:57.387Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/michaeljscript.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-06-13T18:10:21.000Z","updated_at":"2024-01-28T18:20:58.352Z","dependencies_parsed_at":null,"dependency_job_id":"29601145-8f80-4776-8812-c95fb399d6f1","html_url":"https://github.com/michaeljscript/deck-game","commit_stats":null,"previous_names":["michaeljscript/deck-game"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaeljscript%2Fdeck-game","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaeljscript%2Fdeck-game/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaeljscript%2Fdeck-game/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaeljscript%2Fdeck-game/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michaeljscript","download_url":"https://codeload.github.com/michaeljscript/deck-game/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241780472,"owners_count":20019058,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-04T03:37:45.139Z","updated_at":"2025-03-04T03:37:45.581Z","avatar_url":"https://github.com/michaeljscript.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The Deck Game\n\n## Install the game\nRequired tools: NodeJS, Yarn, Git\n\n1. Git pull current repository\n2. `yarn install` to install dependencies\n3. `yarn start` to start development mode\n\n\n## Testing plan\n\n### Unit testing\nFor easy unit testing a refactoring would be needed.\n`react-testing-library` is good for testing React components.\n\nMost of the dummy components located at `src/components` do not need any testing, as they do not include any logic or any hardcoded values.\n\n`src/components/controls.tsx`\n\n- Button element with text \"Draw Card\" is present\n- When clicked on the button, `onDrawClick` is fired\n- Button is disabled when `allowDraw` is set to false or when whole form `Controls` is disabled. By default, it should be enabled.\n\n\n`src/deck-api`\n\n- We can use `jest` as no React is present. \n- We can mock `fetch` to return custom data and to make sure the data manipulation is correct\n\n`src/pages/game.tsx`\n\n- Refactoring would be needed\n- We could make `useDeckGame` to serve data from `React.Context` and by doing that, we can mock anything the `useDeckGame` returns.\n- By using mocked data we can verify that when `loading` is set to `true`, a text \"Loading...\" is displayed\n- By using mocked data we can verify that when `error` is set to `error`, proper error message is displayed\n- By using mocked data we can verify that when game is not loading and has no errors, controls are displayed\n\n\n`src/deck-game-hook`\n\n- Ideally this could be done with `React.Context`\n- Rest API methods are provided by `React.Context` and thus can be easily mocked\n- By using mocked data we can verify that `hasWon` is `true` when the sum of the cards on a table is exactly 21.\n- By using mocked data we can verify that `isBust` is ONLY `true` when the sum of the cards on a table is greater than 21.\n- By using mocked data we can verify that `cardsOnDeskScore` is computed correctly - 10 for face cards, 11 for ace, correct value otherwise\n\n### Integration testing\n\nCypress is a great tool which can be used to test the code. Backend can be isolated by mocking `fetch` requests. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaeljscript%2Fdeck-game","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichaeljscript%2Fdeck-game","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaeljscript%2Fdeck-game/lists"}