{"id":19505151,"url":"https://github.com/alejandroq12/testing-practice","last_synced_at":"2025-06-17T18:34:29.516Z","repository":{"id":68314741,"uuid":"582410369","full_name":"Alejandroq12/testing-practice","owner":"Alejandroq12","description":null,"archived":false,"fork":false,"pushed_at":"2023-04-13T01:06:43.000Z","size":23,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-26T00:33:47.587Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/Alejandroq12.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-26T18:37:14.000Z","updated_at":"2024-02-24T18:53:08.000Z","dependencies_parsed_at":null,"dependency_job_id":"28708fc2-3507-4b54-a130-01f29cbf8452","html_url":"https://github.com/Alejandroq12/testing-practice","commit_stats":null,"previous_names":["alejandroq12/testing-practice"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Alejandroq12/testing-practice","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alejandroq12%2Ftesting-practice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alejandroq12%2Ftesting-practice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alejandroq12%2Ftesting-practice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alejandroq12%2Ftesting-practice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Alejandroq12","download_url":"https://codeload.github.com/Alejandroq12/testing-practice/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alejandroq12%2Ftesting-practice/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260419384,"owners_count":23006265,"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":"2024-11-10T22:28:35.067Z","updated_at":"2025-06-17T18:34:24.500Z","avatar_url":"https://github.com/Alejandroq12.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Notice: this practice will be completed on Saturday/15/2023\n\nIn this exercise, you will write a few practical tests for JavaScript functions using the Jest library. I should make sure I follow the AAA pattern to make my tests easier for other developers to read and understand. I will also try to use the TDD approach in practice.\n\n#### Task 1\n- Write a function *stringLength(string)* that takes any string as an argument and returns its characters count.\n- Now write a test for this function.\n- Next, expand the function to make it check if the string is at least 1 character long and not longer than 10 characters. Throw errors if those conditions are not met.\n- Add tests for the new functionality.\n\n#### Task 2\n- Write a function *reverseString(string)* function. It should take a string as an argument and return it reversed.\n- Write at least one test for this function.\n\n#### Task 3\nIn this task, I will need to write several tests for each tested function. I could write all of the tests directly at the top level, but it's better to group related tests so their output is more readable. *Jest* has the `describe()` method just for that. Read about it [here](https://jestjs.io/docs/api#describename-fn) and apply it in the tests for this task:\n\n- Write a simple *calculator* class or object, which will have 4 methods: *add*, *subtract*, *divide*, and *multiply*.\n- Write at least 3 tests for each of the calculator methods.\n- Group tests for each method using `describe()` method.\n\n#### Task 4 \nIn this task we're going to do things differently:\n- Start by writing a test for a *capitalize(string)* function. The test should make sure that this function takes a string as an argument and returns that string with the first character capitalized.\n- Run your test - it should fail because I don’t have the *capitalize(string)* function implemented yet.\n- Now make the tests green by implementing the *capitalize(string)* function. Think about what the minimum amount of code is necessary to pass this test and write it.\n\n\nIn task 4, I have just used the TDD approach for development by writing tests before writing the actual functions. Note the difference in the steps I followed here, compared with those I used in the previous 3 tasks.\n\n## Challenge myself\n\n*Use these questions to check what you learned during this lesson.*\n- What is the next test you can write for *capitalize(string)*?\n- What can go wrong with this function? For example, what happens if someone provides an integer as an input for this function?\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falejandroq12%2Ftesting-practice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falejandroq12%2Ftesting-practice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falejandroq12%2Ftesting-practice/lists"}