Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sahilcreate/top-testing-practice
Practising TDD while following The Odin Project
https://github.com/sahilcreate/top-testing-practice
jest-tests tdd test-driven-development testing
Last synced: about 2 months ago
JSON representation
Practising TDD while following The Odin Project
- Host: GitHub
- URL: https://github.com/sahilcreate/top-testing-practice
- Owner: Sahilcreate
- License: mit
- Created: 2024-12-01T12:07:21.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2024-12-02T11:52:21.000Z (about 2 months ago)
- Last Synced: 2024-12-02T12:33:10.922Z (about 2 months ago)
- Topics: jest-tests, tdd, test-driven-development, testing
- Language: JavaScript
- Homepage: https://github.com/Sahilcreate/top-testing-practice/tree/main/src
- Size: 14.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Project: Testing Practice
This testing thing really is not that difficult, but it is quite new. The only way to get comfortable with it is to spend some time doing it.
## Assignment
Write tests for the following, and then make the test pass!
- [x] 1. A `capitalize` function that takes a string and returns it with the first character capitalized.
- [x] 2. A `reverseString` function that takes a string and returns it reversed.
- [x] 3. A `calculator` object that contains functions for the basic operations: `add`, `subtract`, `divide`, and `multiply`. Each of these functions should take two numbers and return the correct calculation.
- [x] 4. A `caesarCipher` function that takes a string and a shift factor and returns it with each character “shifted”- Don’t forget to test wrapping from `z` to `a`. For example, `caesarCipher('xyz', 3)` should return `'abc'`.
- Don’t forget to test case preservation. The shifted lettercase should follow the original lettercase. For example, `caesarCipher('HeLLo', 3)` should return `'KhOOr'`.
- Don’t forget to test punctuation. Punctuations, spaces, and other non-alphabetical characters should remain unchanged. For example, `caesarCipher('Hello, World!', 3)` should return `'Khoor, Zruog!'`.
- For this one, you may want to split the final function into a few smaller functions. One concept of Testing is that you don’t need to explicitly test every function you write… Just the public ones. So in this case you only need tests for the final `caesarCipher` function. If it works as expected you can rest assured that your smaller helper functions are doing what they’re supposed to.- [x] 5. An `analyzeArray` function that takes an array of numbers and returns an object with the following properties: `average`, `min`, `max`, and `length`.
```
const object = analyzeArray([1,8,3,4,2,6]);object == {
average: 4,
min: 1,
max: 8,
length: 6
};
```