{"id":19458626,"url":"https://github.com/luontola/tdd-mooc-untestable-code","last_synced_at":"2025-04-25T06:30:31.660Z","repository":{"id":66604293,"uuid":"564315764","full_name":"luontola/tdd-mooc-untestable-code","owner":"luontola","description":"Exercise about unit testing legacy code","archived":false,"fork":false,"pushed_at":"2023-12-25T14:19:11.000Z","size":118,"stargazers_count":2,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-03T17:22:57.354Z","etag":null,"topics":["javascript","kata","legacy-code","unit-testing"],"latest_commit_sha":null,"homepage":"https://tdd.mooc.fi","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luontola.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-10T13:05:33.000Z","updated_at":"2023-01-25T10:01:50.000Z","dependencies_parsed_at":"2023-12-25T14:44:49.100Z","dependency_job_id":null,"html_url":"https://github.com/luontola/tdd-mooc-untestable-code","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luontola%2Ftdd-mooc-untestable-code","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luontola%2Ftdd-mooc-untestable-code/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luontola%2Ftdd-mooc-untestable-code/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luontola%2Ftdd-mooc-untestable-code/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luontola","download_url":"https://codeload.github.com/luontola/tdd-mooc-untestable-code/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250766963,"owners_count":21483895,"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":["javascript","kata","legacy-code","unit-testing"],"created_at":"2024-11-10T17:27:54.521Z","updated_at":"2025-04-25T06:30:31.305Z","avatar_url":"https://github.com/luontola.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [TDD MOOC](https://tdd.mooc.fi): Untestable Code\n\nThis is an exercise for learning about unit testing and writing testable code.\n\nYou have been given four examples of untestable or at least hard-to-test code.\nSee the `src` and `test` directories.\nThe examples are numbered 1 to 4, in order of difficulty.\n\n**First determine that what things make the code examples hard to test.**\n(See [Chapter 3](https://tdd.mooc.fi/3-challenges) of the course material.)\nWrite your learnings as comments in the untestable code.\n\n**Then create a copy of the untestable code, refactor it to be easily testable, and write tests for it.**\n\nP.S. If you want an extra challenge, also write tests for the original untestable code. Then compare the tests you wrote\nfor the refactored code and the original code, and see how much more complicated they are.\n\n---\n\n_This exercise is part of the [TDD MOOC](https://tdd.mooc.fi) at the University of Helsinki, brought to you\nby [Esko Luontola](https://twitter.com/EskoLuontola) and [Nitor](https://nitor.com/)._\n\n## Prerequisites\n\nYou'll need a recent [Node.js](https://nodejs.org/) version. Then download this project's dependencies with:\n\n    npm install\n\nPart 4 of this exercise provides [Docker](https://www.docker.com/products/docker-desktop/) configuration for starting\nthe database, but you may also run [PostgreSQL](https://www.postgresql.org/download/) without containers.\n\n## Developing\n\nStart the database (used by untestable4)\n\n    docker compose up -d\n\nThis will start a [PostgreSQL 13](https://www.postgresql.org/docs/13/index.html) database to which you can connect using\nthe following settings:\n\n- Host: `localhost`\n- Port: `5432`\n- User: `untestable`\n- Password: `secret`\n- Database: `untestable`\n- It will also create a `users` table in the `public` schema based on [src/create-tables.sql](src/create-tables.sql)\n\nStop and destroy the database\n\n    docker compose down\n\nRun tests once\n\n    npm run test\n\nRun tests continuously\n\n    npm run autotest\n\nCode reformat\n\n    npm run format\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluontola%2Ftdd-mooc-untestable-code","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluontola%2Ftdd-mooc-untestable-code","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluontola%2Ftdd-mooc-untestable-code/lists"}