{"id":21964640,"url":"https://github.com/apollo-level2-web-dev/l2-b1-assignment-10","last_synced_at":"2025-03-22T21:25:03.276Z","repository":{"id":206517748,"uuid":"716533589","full_name":"Apollo-Level2-Web-Dev/l2-b1-assignment-10","owner":"Apollo-Level2-Web-Dev","description":null,"archived":false,"fork":false,"pushed_at":"2023-11-09T18:53:29.000Z","size":3,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-01-28T01:16:59.624Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"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/Apollo-Level2-Web-Dev.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}},"created_at":"2023-11-09T10:37:08.000Z","updated_at":"2024-04-02T00:00:35.000Z","dependencies_parsed_at":"2023-11-10T16:25:06.149Z","dependency_job_id":"64f6b98f-a4cb-4a32-82d9-c002011c22dc","html_url":"https://github.com/Apollo-Level2-Web-Dev/l2-b1-assignment-10","commit_stats":null,"previous_names":["apollo-level2-web-dev/l2-b1-assignment-10"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Apollo-Level2-Web-Dev%2Fl2-b1-assignment-10","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Apollo-Level2-Web-Dev%2Fl2-b1-assignment-10/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Apollo-Level2-Web-Dev%2Fl2-b1-assignment-10/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Apollo-Level2-Web-Dev%2Fl2-b1-assignment-10/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Apollo-Level2-Web-Dev","download_url":"https://codeload.github.com/Apollo-Level2-Web-Dev/l2-b1-assignment-10/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245021714,"owners_count":20548392,"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-29T12:26:19.358Z","updated_at":"2025-03-22T21:25:03.246Z","avatar_url":"https://github.com/Apollo-Level2-Web-Dev.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"**Level 2 Batch 1 Assignment 10**\n\n**Unit-1**\n\n```powershell\nfunction divide(a, b) {\n  if (b === 0) {\n    throw new Error('Division by zero');\n  }\n  return a / b;\n}\n```\n\n**Test Cases:**\n\n1. **Valid Division**:\n    - Test that the function correctly divides two positive numbers.\n    - Example: **`divide(10, 2)`** should return **`5`**.\n2. **Valid Division with Negative Numbers**:\n    - Test that the function correctly handles division with negative numbers.\n    - Example: **`divide(-10, 2)`** should return **`5`**.\n3. **Division by Zero**:\n    - Test that the function throws an error when attempting to divide by zero.\n    - Example: **`divide(5, 0)`** should throw an **`Error`** with the message 'Division by zero'.\n\n**Unit-2**\n\n```jsx\nfunction executeCallback(callback, taskText) {\n  callback(taskText);\n}\n\nfunction myCallback(taskText) {\n  console.log(`Task: ${taskText}`);\n}\n\n// Call executeCallback with a callback function and a task text\n\nexecuteCallback(myCallback, \"Buy groceries\");\n```\n\n**Test Cases:**\n\n1. **Callback Execution**:\n    - Test that the **`executeCallback`** function correctly calls the provided callback function.\n2. **Callback Execution with Task Text**:\n    - Verify that the callback function is executed with the provided **`taskText`** argument.\n    - Example: When **`executeCallback(callback, \"Buy groceries\")`** is called, ensure that the **`callback`** function is invoked with the argument \"Buy groceries.\"\n\n**Unit-3**\n\n```jsx\nfunction fetchData() {\n  return new Promise((resolve, reject) =\u003e {\n    // Simulate an async operation (e.g., fetching data from an API)\n    setTimeout(() =\u003e {\n      const data = { name: 'John', age: 30 };\n      resolve(data);\n    }, 1000); // Simulate a 1-second delay\n  });\n}\n```\n\n**Test Cases:**\n\n**Successful Data Fetch**:\n\n- Test that the **`fetchData`** function resolves with the correct data when the asynchronous operation is successful.\n- For example, you can verify that the function resolves with **`{ name: 'John', age: 30 }`** when the Promise resolves.\n\n**Error Handling**:\n\n- Test how the function handles errors. You can create a modified version of **`fetchData`** that rejects the Promise with an error and test that it throws an error.\n- For example, ensure that calling **`fetchData`** with a specific argument or configuration correctly rejects the Promise with an error message.\n\n### **General Guidelines:**\n\n- Use the Vitest or Jest framework to write and run your tests. Make sure your tests are written following the best practices.\n- Comment your code as needed to explain the purpose of your tests and any significant steps you are taking.\n- Ensure that your test cases are independent of each other, meaning the outcome of one test should not affect the others.\n- Aim for comprehensive test coverage, testing both expected behavior and error conditions where applicable.\n\n### **Deadline:**\n\n- 60 marks: November 12, 2023, 11:59 PM\n- 50 marks: November 13, 2023, 11:59 PM\n- 30 marks: After 13th November, 11.59PM\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapollo-level2-web-dev%2Fl2-b1-assignment-10","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapollo-level2-web-dev%2Fl2-b1-assignment-10","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapollo-level2-web-dev%2Fl2-b1-assignment-10/lists"}