Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vikyw89/testingpractice
https://github.com/vikyw89/testingpractice
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/vikyw89/testingpractice
- Owner: vikyw89
- License: mit
- Created: 2023-01-24T03:53:23.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-24T07:30:11.000Z (almost 2 years ago)
- Last Synced: 2024-10-12T08:45:43.961Z (2 months ago)
- Language: JavaScript
- Size: 47.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# testingPractice
to run, clone this repo and type these in CLI:
```
npm install
npm run test
```
Assignment
Write tests for the following, and then make the tests pass!
A
capitalize
function that takes a string and returns it with the first character capitalized.
A
reverseString
function that takes a string and returns it reversed.
A
calculator
object that contains functions for the basic operations:add
,subtract
,divide
, andmultiply
. Each of these functions should take two numbers and return the correct calculation.
A
caesarCipher
function that takes a string and a shift factor and returns it with each character “shifted”. Read more about how a Caesar cipher works on this website.
- Don’t forget to test wrapping from
z
toa
.
- Don’t forget to test keeping the same case.
- Don’t forget to test punctuation!
- 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.
An
analyzeArray
function that takes an array of numbers and returns an object with the following properties:average
,min
,max
, andlength
.
const object = analyzeArray([1,8,3,4,2,6]);
object == {
average: 4,
min: 1,
max: 8,
length: 6
};