Added jest
Removed generator-exercises folder as it breaks jest-codemods run jest-codemods on .spec.js files, move generator-exercises back in Change references from Jasmine to Jest in main readme Update README with Jest specific language. Update some spec files with new syntax update tests, multiple exercises .gitignore: Added package-lock.json, package.json that were used when I ran code-blocks over the tests. Standardised function declaration calls across exercises fix typo in caesar.spec.js Ignoring package-lock.json, package.json Backtrack on .gitignore modification, add instructions to readme move files from testing repo to this repo Typo fixes, remove duplicate exercise folder Remove solution from non-solution branch Minor grammatical fixes added trailing semicolon to all function and module exports Fix words caught by search/replace action. remove doubled semicolon. Correct words caught by search/replace action. Add missing semicolon. Add .DS_Store to .gitignore multiple files: Added a blank line at the end of each file Ignore generator-exercise when linting exercise files Update exercise number of each exercise Update exercise number
This commit is contained in:
parent
4c771f2e05
commit
5708c3d85a
|
@ -0,0 +1 @@
|
|||
generator-exercise/
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"plugins": [
|
||||
"import"
|
||||
],
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 12,
|
||||
"sourceType": "module"
|
||||
},
|
||||
"rules": {
|
||||
"eol-last": ["error", "always"]
|
||||
}
|
||||
}
|
|
@ -1 +1,3 @@
|
|||
.vscode
|
||||
node_modules/
|
||||
.DS_Store
|
|
@ -9,10 +9,12 @@ There will eventually be a suggested order of completion, but at this time since
|
|||
## How To Use These Exercises
|
||||
Before you start you should have a few things installed on your machine:
|
||||
1. NPM. To check if you have NPM installed, type `npm --version` in your terminal. If you get back `Command 'npm' not found, but can be installed with:`, do NOT follow the instructions in the terminal to install with `apt-get`. (This causes permission issues.) Instead, install Node with NVM by following the instructions [here](https://github.com/TheOdinProject/curriculum/blob/master/foundations/installations/installing_node.md).
|
||||
2. Jasmine. Jasmine is a testing framework for JavaScript. Type `jasmine -v` to check for it. If you need to install it, type `npm install -g jasmine` to do so.
|
||||
3. A copy of this repository. Copies of repositories on your machine are called clones. If you need help cloning, you can learn how [here](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository)
|
||||
2. Jest. Jest is a testing framework for JavaScript. To install it, type `npm install --save-dev jest`. We use `--save-dev` here to specify this module is for development purposes only.
|
||||
3. A copy of this repository. Copies of repositories on your machine are called clones. If you need help cloning, you can learn how [here](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/cloning-a-repository).
|
||||
|
||||
Each exercise includes 3 files: a markdown file with a description of the task, an empty (or mostly empty) JavaScript file, and a set of tests. To complete an exercise, you'll need to go to the exercise directory with `cd exerciseName` in the terminal and run `jasmine exerciseName.spec.js`. This should run the test file and show you the output. When you first run a test, it will fail. This is by design! You must open the exercise file and write the code needed to get the test to pass. Some of the exercises have test conditions defined in their spec file that are defined as 'xit' compared to 'it'. This is purposeful. After you pass your first 'it', you will change the next 'xit' to an 'it' and test your code again. You'll do this until all conditions are satisfied.
|
||||
Each exercise includes 3 files: a markdown file with a description of the task, an empty (or mostly empty) JavaScript file, and a set of tests. To complete an exercise, you'll need to go to the exercise directory with `cd exerciseName` in the terminal and run `npm test exerciseName.spec.js`. This should run the test file and show you the output. When you first run a test, it will fail. This is by design! You must open the exercise file and write the code needed to get the test to pass. Some of the exercises have test conditions defined in their spec file that are defined as 'test.skip' compared to 'test'. This is purposeful. After you pass your first 'test', you will change the next 'test.skip' to an 'test' and test your code again. You'll do this until all conditions are satisfied.
|
||||
|
||||
**Note**: Due to the way Jest handles failed tests, it may return an exit code of 1 if any tests fail. NPM will interpret this as an error and you may see some `npm ERR!` messages after Jest runs. You can ignore these, or run your test with `npm test exerciseName.spec.js --silent` to supress the errors.
|
||||
|
||||
The first exercise, `helloWorld`, will walk you through the process in-depth.
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Exercise XX - caesar cipher
|
||||
# Exercise 13 - Caesar cipher
|
||||
|
||||
Implement the legendary caesar cipher:
|
||||
Implement the legendary Caesar cipher:
|
||||
|
||||
> In cryptography, a Caesar cipher, also known as Caesar's cipher, the shift cipher, Caesar's code or Caesar shift, is one of the simplest and most widely known encryption techniques. It is a type of substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet. For example, with a left shift of 3, D would be replaced by A, E would become B, and so on. The method is named after Julius Caesar, who used it in his private correspondence.
|
||||
|
||||
|
@ -31,5 +31,3 @@ negative numbers should work as well:
|
|||
```javascript
|
||||
caesar('Mjqqt, Btwqi!', -5) // returns 'Hello, World!'
|
||||
```
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const caesar = function() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = caesar
|
||||
module.exports = caesar;
|
||||
|
|
|
@ -1,25 +1,23 @@
|
|||
const caesar = require('./caesar')
|
||||
|
||||
describe('caesar', function() {
|
||||
it('works with single letters', function() {
|
||||
expect(caesar('A', 1)).toEqual('B');
|
||||
test('works with single letters', () => {
|
||||
expect(caesar('A', 1)).toBe('B');
|
||||
});
|
||||
xit('works with words', function() {
|
||||
expect(caesar('Aaa', 1)).toEqual('Bbb');
|
||||
test.skip('works with words', () => {
|
||||
expect(caesar('Aaa', 1)).toBe('Bbb');
|
||||
});
|
||||
xit('works with phrases', function() {
|
||||
expect(caesar('Hello, World!', 5)).toEqual('Mjqqt, Btwqi!');
|
||||
test.skip('works with phrases', () => {
|
||||
expect(caesar('Hello, World!', 5)).toBe('Mjqqt, Btwqi!');
|
||||
});
|
||||
xit('works with negative shift', function() {
|
||||
expect(caesar('Mjqqt, Btwqi!', -5)).toEqual('Hello, World!');
|
||||
test.skip('works with negative shift', () => {
|
||||
expect(caesar('Mjqqt, Btwqi!', -5)).toBe('Hello, World!');
|
||||
});
|
||||
xit('wraps', function() {
|
||||
expect(caesar('Z', 1)).toEqual('A');
|
||||
test.skip('wraps', () => {
|
||||
expect(caesar('Z', 1)).toBe('A');
|
||||
});
|
||||
xit('works with large shift factors', function() {
|
||||
expect(caesar('Hello, World!', 75)).toEqual('Ebiil, Tloia!');
|
||||
});
|
||||
xit('works with large negative shift factors', function() {
|
||||
expect(caesar('Hello, World!', -29)).toEqual('Ebiil, Tloia!');
|
||||
test.skip('works with large shift factors', () => {
|
||||
expect(caesar('Hello, World!', 75)).toBe('Ebiil, Tloia!');
|
||||
});
|
||||
test.skip('works with large negative shift factors', () => {
|
||||
expect(caesar('Hello, World!', -29)).toBe('Ebiil, Tloia!');
|
||||
});
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
# Exercise 08 - Calculator
|
||||
|
||||
The goal for this exercise is to create a calculator that does the following:
|
||||
|
||||
add, subtract, get the sum, multiply, get the power, and find the factorial
|
||||
|
||||
In order to do this please fill out each function with your solution. Make sure to return the value so you can test it in Jasmine! To see the expected value
|
||||
take a look at the spec file that houses the Jasmine test cases.
|
||||
In order to do this please fill out each function with your solution. Make sure to return the value so you can test it in Jest! To see the expected value
|
||||
take a look at the spec file that houses the Jest test cases.
|
|
@ -1,26 +1,26 @@
|
|||
function add () {
|
||||
const add = function() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
function subtract () {
|
||||
const subtract = function() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
function sum () {
|
||||
const sum = function() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
function multiply () {
|
||||
const multiply = function() {
|
||||
|
||||
}
|
||||
};;
|
||||
|
||||
function power() {
|
||||
const power = function() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
function factorial() {
|
||||
const factorial = function() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
add,
|
||||
|
@ -29,4 +29,4 @@ module.exports = {
|
|||
multiply,
|
||||
power,
|
||||
factorial
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,77 +1,77 @@
|
|||
const calculator = require ('./calculator.js');
|
||||
const calculator = require('./calculator');
|
||||
|
||||
describe('add', function() {
|
||||
it('adds 0 and 0', function() {
|
||||
expect(calculator.add(0,0)).toEqual(0);
|
||||
describe('add', () => {
|
||||
test('adds 0 and 0', () => {
|
||||
expect(calculator.add(0,0)).toBe(0);
|
||||
});
|
||||
|
||||
xit('adds 2 and 2', function() {
|
||||
expect(calculator.add(2,2)).toEqual(4);
|
||||
test.skip('adds 2 and 2', () => {
|
||||
expect(calculator.add(2,2)).toBe(4);
|
||||
});
|
||||
|
||||
xit('adds positive numbers', function() {
|
||||
expect(calculator.add(2,6)).toEqual(8);
|
||||
test.skip('adds positive numbers', () => {
|
||||
expect(calculator.add(2,6)).toBe(8);
|
||||
});
|
||||
});
|
||||
|
||||
describe('subtract', function() {
|
||||
xit('subtracts numbers', function() {
|
||||
expect(calculator.subtract(10,4)).toEqual(6);
|
||||
describe('subtract', () => {
|
||||
test.skip('subtracts numbers', () => {
|
||||
expect(calculator.subtract(10,4)).toBe(6);
|
||||
});
|
||||
});
|
||||
|
||||
describe('sum', function() {
|
||||
xit('computes the sum of an empty array', function() {
|
||||
expect(calculator.sum([])).toEqual(0);
|
||||
describe('sum', () => {
|
||||
test.skip('computes the sum of an empty array', () => {
|
||||
expect(calculator.sum([])).toBe(0);
|
||||
});
|
||||
|
||||
xit('computes the sum of an array of one number', function() {
|
||||
expect(calculator.sum([7])).toEqual(7);
|
||||
test.skip('computes the sum of an array of one number', () => {
|
||||
expect(calculator.sum([7])).toBe(7);
|
||||
});
|
||||
|
||||
xit('computes the sum of an array of two numbers', function() {
|
||||
expect(calculator.sum([7,11])).toEqual(18);
|
||||
test.skip('computes the sum of an array of two numbers', () => {
|
||||
expect(calculator.sum([7,11])).toBe(18);
|
||||
});
|
||||
|
||||
xit('computes the sum of an array of many numbers', function() {
|
||||
expect(calculator.sum([1,3,5,7,9])).toEqual(25);
|
||||
test.skip('computes the sum of an array of many numbers', () => {
|
||||
expect(calculator.sum([1,3,5,7,9])).toBe(25);
|
||||
});
|
||||
});
|
||||
|
||||
describe('multiply', function() {
|
||||
xit('multiplies two numbers', function() {
|
||||
expect(calculator.multiply([2,4])).toEqual(8);
|
||||
describe('multiply', () => {
|
||||
test.skip('multiplies two numbers', () => {
|
||||
expect(calculator.multiply([2,4])).toBe(8);
|
||||
});
|
||||
|
||||
xit('multiplies several numbers', function() {
|
||||
expect(calculator.multiply([2,4,6,8,10,12,14])).toEqual(645120);
|
||||
test.skip('multiplies several numbers', () => {
|
||||
expect(calculator.multiply([2,4,6,8,10,12,14])).toBe(645120);
|
||||
});
|
||||
});
|
||||
|
||||
describe('power', function() {
|
||||
xit('raises one number to the power of another number', function() {
|
||||
expect(calculator.power(4,3)).toEqual(64); // 4 to third power is 64
|
||||
describe('power', () => {
|
||||
test.skip('raises one number to the power of another number', () => {
|
||||
expect(calculator.power(4,3)).toBe(64); // 4 to third power is 64
|
||||
});
|
||||
});
|
||||
|
||||
describe('factorial', function() {
|
||||
xit('computes the factorial of 0', function() {
|
||||
expect(calculator.factorial(0)).toEqual(1); // 0! = 1
|
||||
describe('factorial', () => {
|
||||
test.skip('computes the factorial of 0', () => {
|
||||
expect(calculator.factorial(0)).toBe(1); // 0! = 1
|
||||
});
|
||||
|
||||
xit('computes the factorial of 1', function() {
|
||||
expect(calculator.factorial(1)).toEqual(1);
|
||||
test.skip('computes the factorial of 1', () => {
|
||||
expect(calculator.factorial(1)).toBe(1);
|
||||
});
|
||||
|
||||
xit('computes the factorial of 2', function() {
|
||||
expect(calculator.factorial(2)).toEqual(2);
|
||||
test.skip('computes the factorial of 2', () => {
|
||||
expect(calculator.factorial(2)).toBe(2);
|
||||
});
|
||||
|
||||
xit('computes the factorial of 5', function() {
|
||||
expect(calculator.factorial(5)).toEqual(120);
|
||||
test.skip('computes the factorial of 5', () => {
|
||||
expect(calculator.factorial(5)).toBe(120);
|
||||
});
|
||||
|
||||
xit('computes the factorial of 10', function() {
|
||||
expect(calculator.factorial(10)).toEqual(3628800);
|
||||
test.skip('computes the factorial of 10', () => {
|
||||
expect(calculator.factorial(10)).toBe(3628800);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# Exercise XX - fibonacci
|
||||
# Exercise 10 - Fibonacci
|
||||
|
||||
Create a function that returns a specific member of the fibonacci sequence:
|
||||
Create a function that returns a specific member of the Fibonacci sequence:
|
||||
|
||||
> a series of numbers in which each number ( Fibonacci number ) is the sum of the two preceding numbers. The simplest is the series 1, 1, 2, 3, 5, 8, etc.
|
||||
> A series of numbers in which each number ( Fibonacci number ) is the sum of the two preceding numbers. The simplest is the series 1, 1, 2, 3, 5, 8, etc.
|
||||
|
||||
```javascript
|
||||
fibonacci(4) // returns the 4th member of the series: 3 (1, 1, 2, 3)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const fibonacci = function() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = fibonacci
|
||||
module.exports = fibonacci;
|
||||
|
|
|
@ -1,31 +1,31 @@
|
|||
const fibonacci = require('./fibonacci')
|
||||
|
||||
describe('fibonacci', function() {
|
||||
it('works', function() {
|
||||
expect(fibonacci(4)).toEqual(3);
|
||||
describe('fibonacci', () => {
|
||||
test('4th fibonacci number is 3', () => {
|
||||
expect(fibonacci(4)).toBe(3);
|
||||
});
|
||||
xit('works', function() {
|
||||
expect(fibonacci(6)).toEqual(8);
|
||||
test.skip('6th fibonacci number is 8', () => {
|
||||
expect(fibonacci(6)).toBe(8);
|
||||
});
|
||||
xit('works', function() {
|
||||
expect(fibonacci(10)).toEqual(55);
|
||||
test.skip('10th fibonacci number is 55', () => {
|
||||
expect(fibonacci(10)).toBe(55);
|
||||
});
|
||||
xit('works', function() {
|
||||
expect(fibonacci(15)).toEqual(610);
|
||||
test.skip('15th fibonacci number is 610', () => {
|
||||
expect(fibonacci(15)).toBe(610);
|
||||
});
|
||||
xit('works', function() {
|
||||
expect(fibonacci(25)).toEqual(75025);
|
||||
test.skip('25th fibonacci number is 75025', () => {
|
||||
expect(fibonacci(25)).toBe(75025);
|
||||
});
|
||||
xit('doesn\'t accept negatives', function() {
|
||||
expect(fibonacci(-25)).toEqual("OOPS");
|
||||
test.skip('doesn\'t accept negatives', () => {
|
||||
expect(fibonacci(-25)).toBe("OOPS");
|
||||
});
|
||||
xit('DOES accept strings', function() {
|
||||
expect(fibonacci("1")).toEqual(1);
|
||||
test.skip('DOES accept strings', () => {
|
||||
expect(fibonacci("1")).toBe(1);
|
||||
});
|
||||
xit('DOES accept strings', function() {
|
||||
expect(fibonacci("2")).toEqual(1);
|
||||
test.skip('DOES accept strings', () => {
|
||||
expect(fibonacci("2")).toBe(1);
|
||||
});
|
||||
xit('DOES accept strings', function() {
|
||||
expect(fibonacci("8")).toEqual(21);
|
||||
test.skip('DOES accept strings', () => {
|
||||
expect(fibonacci("8")).toBe(21);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
# Find the Oldest
|
||||
# Exercise 12 - Find the Oldest
|
||||
|
||||
given an array of objects representing people with a birth and death year, return the oldest person.
|
||||
Given an array of objects representing people with a birth and death year, return the oldest person.
|
||||
|
||||
## Hints
|
||||
- You should return the whole person object, but the tests mostly just check to make sure the name is correct.
|
||||
- this can be done with a couple of chained array methods, or by using `reduce`.
|
||||
- One of the tests checks for people with no death-date.. use JavaScript's Date function to get their age as of today.
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
let findTheOldest = function() {
|
||||
const findTheOldest = function() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = findTheOldest
|
||||
module.exports = findTheOldest;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
let findTheOldest = require('./findTheOldest')
|
||||
const findTheOldest = require('./findTheOldest')
|
||||
|
||||
describe('findTheOldest', function() {
|
||||
it('finds the oldest person!', function() {
|
||||
describe('findTheOldest', () => {
|
||||
test('finds the oldest person!', () => {
|
||||
const people = [
|
||||
{
|
||||
name: 'Carly',
|
||||
|
@ -19,9 +19,9 @@ describe('findTheOldest', function() {
|
|||
yearOfDeath: 1941
|
||||
},
|
||||
]
|
||||
expect(findTheOldest(people).name).toEqual('Ray');
|
||||
expect(findTheOldest(people).name).toBe('Ray');
|
||||
});
|
||||
xit('finds the oldest person if someone is still living', function() {
|
||||
test.skip('finds the oldest person if someone is still living', () => {
|
||||
const people = [
|
||||
{
|
||||
name: 'Carly',
|
||||
|
@ -38,9 +38,9 @@ describe('findTheOldest', function() {
|
|||
yearOfDeath: 1941
|
||||
},
|
||||
]
|
||||
expect(findTheOldest(people).name).toEqual('Ray');
|
||||
expect(findTheOldest(people).name).toBe('Ray');
|
||||
});
|
||||
xit('finds the oldest person if the OLDEST is still living', function() {
|
||||
test.skip('finds the oldest person if the OLDEST is still living', () => {
|
||||
const people = [
|
||||
{
|
||||
name: 'Carly',
|
||||
|
@ -57,7 +57,7 @@ describe('findTheOldest', function() {
|
|||
yearOfDeath: 1941
|
||||
},
|
||||
]
|
||||
expect(findTheOldest(people).name).toEqual('Carly');
|
||||
expect(findTheOldest(people).name).toBe('Carly');
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
let <%= title %> = function() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = <%= title %>
|
||||
module.exports = <%= title %>;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
let <%= title %> = require('./<%=title%>')
|
||||
|
||||
describe('<%=title%>', function() {
|
||||
it('EDITME', function() {
|
||||
test('EDITME', function() {
|
||||
expect(<%=title%>()).toEqual(' ');
|
||||
});
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Get the Titles!
|
||||
# Exercise 11 - Get the Titles!
|
||||
|
||||
You are given an array of objects that represent books with an author and a title that looks like this:
|
||||
|
||||
|
@ -15,7 +15,7 @@ const books = [
|
|||
]
|
||||
```
|
||||
|
||||
your job is to write a function that takes the array and returns an array of titles:
|
||||
Your job is to write a function that takes the array and returns an array of titles:
|
||||
|
||||
```javascript
|
||||
getTheTitles(books) // ['Book','Book2']
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const getTheTitles = function() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = getTheTitles;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
let getTheTitles = require('./getTheTitles')
|
||||
const getTheTitles = require('./getTheTitles')
|
||||
|
||||
describe('getTheTitles', function() {
|
||||
describe('getTheTitles', () => {
|
||||
const books = [
|
||||
{
|
||||
title: 'Book',
|
||||
|
@ -12,7 +12,7 @@ describe('getTheTitles', function() {
|
|||
}
|
||||
]
|
||||
|
||||
it('gets titles', function() {
|
||||
test('gets titles', () => {
|
||||
expect(getTheTitles(books)).toEqual(['Book','Book2']);
|
||||
});
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Exercise 01 - Hello World.
|
||||
# Exercise 01 - Hello World
|
||||
|
||||
The main purpose of this exercise is to walk you through the process of running the tests and make sure everything is set up and running correctly.
|
||||
|
||||
|
@ -13,16 +13,16 @@ Let's look at the spec file first:
|
|||
const helloWorld = require('./helloWorld');
|
||||
|
||||
describe('Hello World', function() {
|
||||
it('says hello world', function() {
|
||||
test('says hello world', function() {
|
||||
expect(helloWorld()).toEqual('Hello, World!');
|
||||
});
|
||||
});
|
||||
```
|
||||
At the very top of the file we use `require()` to import the code from the javascript file (`helloWorld.js`) so that we can test it.
|
||||
|
||||
The next block (`describe()`) is the body of the test. Basically, all it's doing is running your code and testing to see if the output is correct. The `it()` function describes what should be happening in plain english and then includes the `expect()` function. For this simple example it should be pretty simple to read.
|
||||
The next block (`describe()`) is the body of the test. Basically, all it's doing is running your code and testing to see if the output is correct. The `test()` function describes what should be happening in plain english and then includes the `expect()` function. For this simple example it should be pretty simple to read.
|
||||
|
||||
For now you do not need to worry about how to write tests, but you should try to get comfortable enough with the syntax to figure out what the tests are asking you to do. Go ahead and run the tests by entering `jasmine helloWorld.spec.js` in the terminal and watch it fail. The output from that command should tell you exactly what went wrong with your code. In this case, running the `helloWorld()` function should return the phrase 'Hello, World!' but instead it returns an empty string...
|
||||
For now you do not need to worry about how to write tests, but you should try to get comfortable enough with the syntax to figure out what the tests are asking you to do. Go ahead and run the tests by entering `npm test helloWorld.spec.js` in the terminal and watch it fail. The output from that command should tell you exactly what went wrong with your code. In this case, running the `helloWorld()` function should return the phrase 'Hello, World!' but instead it returns an empty string...
|
||||
|
||||
so let's look at the javascript file:
|
||||
```javascript
|
||||
|
|
|
@ -2,4 +2,4 @@ const helloWorld = function() {
|
|||
return ''
|
||||
}
|
||||
|
||||
module.exports = helloWorld
|
||||
module.exports = helloWorld;
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
const helloWorld = require('./helloWorld');
|
||||
|
||||
describe('Hello World', function() {
|
||||
it('says hello world', function() {
|
||||
expect(helloWorld()).toEqual('Hello, World!');
|
||||
});
|
||||
test('says "Hello, World!"', function() {
|
||||
expect(helloWorld()).toBe("Hello, World!");
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Exercise XX - leapYears
|
||||
# Exercise 06 - leapYears
|
||||
|
||||
Create a function that determines whether or not a given year is a leap year. Leap years are determined by the following rules:
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const leapYears = function() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = leapYears
|
||||
module.exports = leapYears;
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
const leapYears = require('./leapYears')
|
||||
|
||||
describe('leapYears', function() {
|
||||
it('works with non century years', function() {
|
||||
expect(leapYears(1996)).toEqual(true);
|
||||
describe('leapYears', () => {
|
||||
test('works with non century years', () => {
|
||||
expect(leapYears(1996)).toBe(true);
|
||||
});
|
||||
xit('works with non century years', function() {
|
||||
expect(leapYears(1997)).toEqual(false);
|
||||
test.skip('works with non century years', () => {
|
||||
expect(leapYears(1997)).toBe(false);
|
||||
});
|
||||
xit('works with ridiculously futuristic non century years', function() {
|
||||
expect(leapYears(34992)).toEqual(true);
|
||||
test.skip('works with ridiculously futuristic non century years', () => {
|
||||
expect(leapYears(34992)).toBe(true);
|
||||
});
|
||||
xit('works with century years', function() {
|
||||
expect(leapYears(1900)).toEqual(false);
|
||||
test.skip('works with century years', () => {
|
||||
expect(leapYears(1900)).toBe(false);
|
||||
});
|
||||
xit('works with century years', function() {
|
||||
expect(leapYears(1600)).toEqual(true);
|
||||
test.skip('works with century years', () => {
|
||||
expect(leapYears(1600)).toBe(true);
|
||||
});
|
||||
xit('works with century years', function() {
|
||||
expect(leapYears(700)).toEqual(false);
|
||||
test.skip('works with century years', () => {
|
||||
expect(leapYears(700)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"name": "javascript-exercises",
|
||||
"version": "1.0.0",
|
||||
"description": "These are a series of javascript exercises intended to be used alongside the curriculum at 'The Odin Project' They start off nice and easy, but get more involved as you progress through them.",
|
||||
"main": "index.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/TheOdinProject/javascript-exercises.git"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/TheOdinProject/javascript-exercises/issues"
|
||||
},
|
||||
"homepage": "https://github.com/TheOdinProject/javascript-exercises#readme",
|
||||
"devDependencies": {
|
||||
"jest": "^26.6.3",
|
||||
"jest-cli": "^26.6.3",
|
||||
"eslint": "^7.26.0",
|
||||
"eslint-config-airbnb-base": "^14.2.1",
|
||||
"eslint-plugin-import": "^2.22.1"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "jest"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"root": true
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
# Exercise XX - palindromes
|
||||
# Exercise 09 - Palindromes
|
||||
|
||||
Write a function that determines whether or not a given string is a palindrome.
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const palindromes = function() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = palindromes
|
||||
module.exports = palindromes;
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
const palindromes = require('./palindromes')
|
||||
|
||||
describe('palindromes', function() {
|
||||
it('works with single words', function() {
|
||||
expect(palindromes('racecar')).toEqual(true);
|
||||
describe('palindromes', () => {
|
||||
test('works with single words', () => {
|
||||
expect(palindromes('racecar')).toBe(true);
|
||||
});
|
||||
xit('works with punctuation ', function() {
|
||||
expect(palindromes('racecar!')).toEqual(true);
|
||||
test.skip('works with punctuation ', () => {
|
||||
expect(palindromes('racecar!')).toBe(true);
|
||||
});
|
||||
xit('works with upper-case letters ', function() {
|
||||
expect(palindromes('Racecar!')).toEqual(true);
|
||||
test.skip('works with upper-case letters ', () => {
|
||||
expect(palindromes('Racecar!')).toBe(true);
|
||||
});
|
||||
xit('works with multiple words', function() {
|
||||
expect(palindromes('A car, a man, a maraca.')).toEqual(true);
|
||||
test.skip('works with multiple words', () => {
|
||||
expect(palindromes('A car, a man, a maraca.')).toBe(true);
|
||||
});
|
||||
xit('works with multiple words', function() {
|
||||
expect(palindromes('Animal loots foliated detail of stool lamina.')).toEqual(true);
|
||||
test.skip('works with multiple words', () => {
|
||||
expect(palindromes('Animal loots foliated detail of stool lamina.')).toBe(true);
|
||||
});
|
||||
xit('doesn\'t just always return true', function() {
|
||||
expect(palindromes('ZZZZ car, a man, a maraca.')).toEqual(false);
|
||||
test.skip('doesn\'t just always return true', () => {
|
||||
expect(palindromes('ZZZZ car, a man, a maraca.')).toBe(false);
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
function pigLatin(string) {
|
||||
|
||||
};
|
||||
|
||||
module.exports = pigLatin;
|
|
@ -0,0 +1,56 @@
|
|||
const pigLatin = require('./pigLatin')
|
||||
|
||||
// Topics
|
||||
|
||||
// * modules
|
||||
// * strings
|
||||
|
||||
// Pig Latin
|
||||
|
||||
// Pig Latin is a made-up children's language that's intended to be confusing. test obeys a few simple rules (below) but when test's spoken quickly test's really difficult for non-children (and non-native speakers) to understand.
|
||||
|
||||
// Rule 1: If a word begins with a vowel sound, add an "ay" sound to the end of the word.
|
||||
|
||||
// Rule 2: If a word begins with a consonant sound, move test to the end of the word, and then add an "ay" sound to the end of the word.
|
||||
|
||||
// (There are a few more rules for edge cases, and there are regional variants too, but that should be enough to understand the tests.)
|
||||
|
||||
// See https://en.wikipedia.org/wiki/Pig_Latin for more details.
|
||||
|
||||
describe('translate', () => {
|
||||
test('translates a word beginning with a vowel', () => {
|
||||
expect(pigLatin("apple")).toBe('appleay');
|
||||
});
|
||||
|
||||
test.skip('translates a word beginning with a consonant', () => {
|
||||
expect(pigLatin("banana")).toBe("ananabay");
|
||||
});
|
||||
|
||||
test.skip('translates a word beginning with two consonants', () => {
|
||||
expect(pigLatin("cherry")).toBe('errychay');
|
||||
});
|
||||
|
||||
test.skip('translates two words', () => {
|
||||
expect(pigLatin("eat pie")).toBe('eatay iepay');
|
||||
});
|
||||
|
||||
test.skip('translates a word beginning with three consonants', () => {
|
||||
expect(pigLatin("three")).toBe("eethray");
|
||||
});
|
||||
|
||||
test.skip('counts "sch" as a single phoneme', () => {
|
||||
expect(pigLatin("school")).toBe("oolschay");
|
||||
});
|
||||
|
||||
test.skip('counts "qu" as a single phoneme', () => {
|
||||
expect(pigLatin("quiet")).toBe("ietquay");
|
||||
});
|
||||
|
||||
test.skip('counts "qu" as a consonant even when its preceded by a consonant', () => {
|
||||
expect(pigLatin("square")).toBe("aresquay");
|
||||
});
|
||||
|
||||
test.skip('translates many words', () => {
|
||||
expect(pigLatin("the quick brown fox")).toBe("ethay ickquay ownbray oxfay");
|
||||
});
|
||||
});
|
|
@ -1,9 +0,0 @@
|
|||
function translate() {
|
||||
// body...
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
translate
|
||||
}
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
// Topics
|
||||
|
||||
// * modules
|
||||
// * strings
|
||||
|
||||
// Pig Latin
|
||||
|
||||
// Pig Latin is a made-up children's language that's intended to be confusing. It obeys a few simple rules (below) but when it's spoken quickly it's really difficult for non-children (and non-native speakers) to understand.
|
||||
|
||||
// Rule 1: If a word begins with a vowel sound, add an "ay" sound to the end of the word.
|
||||
|
||||
// Rule 2: If a word begins with a consonant sound, move it to the end of the word, and then add an "ay" sound to the end of the word.
|
||||
|
||||
// (There are a few more rules for edge cases, and there are regional variants too, but that should be enough to understand the tests.)
|
||||
|
||||
// See https://en.wikipedia.org/wiki/Pig_Latin for more details.
|
||||
|
||||
const pigLatin = require("./pigLatin.js");
|
||||
|
||||
describe('#translate', function() {
|
||||
it('translates a word beginning with a vowel', function() {
|
||||
s = pigLatin.translate("apple");
|
||||
expect(s).toEqual('appleay');
|
||||
});
|
||||
|
||||
xit('translates a word beginning with a consonant', function() {
|
||||
s = pigLatin.translate("banana");
|
||||
expect(s).toEqual("ananabay");
|
||||
});
|
||||
|
||||
xit('translates a word beginning with two consonants', function() {
|
||||
s = pigLatin.translate("cherry");
|
||||
expect(s).toEqual('errychay');
|
||||
});
|
||||
|
||||
xit('translates two words', function() {
|
||||
s = pigLatin.translate("eat pie");
|
||||
expect(s).toEqual('eatay iepay');
|
||||
});
|
||||
|
||||
xit('translates a word beginning with three consonants', function() {
|
||||
expect(pigLatin.translate("three")).toEqual("eethray");
|
||||
});
|
||||
|
||||
xit('counts "sch" as a single phoneme', function() {
|
||||
s = pigLatin.translate("school");
|
||||
expect(s).toEqual("oolschay");
|
||||
});
|
||||
|
||||
xit('counts "qu" as a single phoneme', function() {
|
||||
s = pigLatin.translate("quiet");
|
||||
expect(s).toEqual("ietquay");
|
||||
});
|
||||
|
||||
xit('counts "qu" as a consonant even when its preceded by a consonant', function() {
|
||||
s = pigLatin.translate("square");
|
||||
expect(s).toEqual("aresquay");
|
||||
});
|
||||
|
||||
xit('translates many words', function() {
|
||||
s = pigLatin.translate("the quick brown fox");
|
||||
expect(s).toEqual("ethay ickquay ownbray oxfay");
|
||||
});
|
||||
});
|
|
@ -8,10 +8,9 @@ removeFromArray([1, 2, 3, 4], 3); // should remove 3 and return [1,2,4]
|
|||
|
||||
## Hints
|
||||
|
||||
the first test on this one is fairly easy, but there are a few things to think about(or google) here for the later tests:
|
||||
The first test on this one is fairly easy, but there are a few things to think about(or google) here for the later tests:
|
||||
|
||||
- how to remove a single element from an array
|
||||
- how to deal with multiple optional arguments in a javascript function
|
||||
- [Check this link](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments). Scroll down to the bit about `Array.from` or the spread operator. - [Or this link](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters).
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const removeFromArray = function() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = removeFromArray
|
||||
module.exports = removeFromArray;
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
const removeFromArray = require('./removeFromArray')
|
||||
|
||||
describe('removeFromArray', function() {
|
||||
it('removes a single value', function() {
|
||||
describe('removeFromArray', () => {
|
||||
test('removes a single value', () => {
|
||||
expect(removeFromArray([1, 2, 3, 4], 3)).toEqual([1, 2, 4]);
|
||||
});
|
||||
xit('removes multiple values', function() {
|
||||
test.skip('removes multiple values', () => {
|
||||
expect(removeFromArray([1, 2, 3, 4], 3, 2)).toEqual([1, 4]);
|
||||
});
|
||||
xit('ignores non present values', function() {
|
||||
test.skip('ignores non present values', () => {
|
||||
expect(removeFromArray([1, 2, 3, 4], 7, "tacos")).toEqual([1, 2, 3, 4]);
|
||||
});
|
||||
xit('ignores non present values, but still works', function() {
|
||||
test.skip('ignores non present values, but still works', () => {
|
||||
expect(removeFromArray([1, 2, 3, 4], 7, 2)).toEqual([1, 3, 4]);
|
||||
});
|
||||
xit('can remove all values', function() {
|
||||
test.skip('can remove all values', () => {
|
||||
expect(removeFromArray([1, 2, 3, 4], 1, 2, 3, 4)).toEqual([]);
|
||||
});
|
||||
xit('works with strings', function() {
|
||||
test.skip('works with strings', () => {
|
||||
expect(removeFromArray(["hey", 2, 3, "ho"], "hey", 3)).toEqual([2, "ho"]);
|
||||
});
|
||||
xit('only removes same type', function() {
|
||||
test.skip('only removes same type', () => {
|
||||
expect(removeFromArray([1, 2, 3], "1", 3)).toEqual([1, 2]);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -6,7 +6,7 @@ Write a function that simply repeats the string a given number of times:
|
|||
repeatString('hey', 3) // returns 'heyheyhey'
|
||||
```
|
||||
|
||||
You will notice in this exercise that there are multiple tests (see in file `repeatString.spec.js`). Only the first test is currently enabled. So after making sure that this first one passes, enable the others one by one by deleting the `x` in front of the `it()` function.
|
||||
You will notice in this exercise that there are multiple tests (see in file `repeatString.spec.js`). Only the first test is currently enabled. So after making sure that this first one passes, enable the others one by one by deleting the `.skip` from the `test.skip()` function.
|
||||
|
||||
|
||||
## Hints
|
||||
|
@ -15,4 +15,11 @@ You will notice in this exercise that there are multiple tests (see in file `rep
|
|||
|
||||
- Create a variable to hold the string you're going to return, create a loop that repeats the given number of times and add the given string to the result on each loop.
|
||||
|
||||
- If running `jasmine repeatString.spec.js` raises `Temporarily disabled with xit` errors, make sure you have enabled the rest of the tests (see above).
|
||||
- If running `npm test repeatString.spec.js` returns results similar to the below:
|
||||
|
||||
```
|
||||
Test Suites: 1 passed, 1 total
|
||||
Tests: 6 skipped, 1 passed, 7 total
|
||||
```
|
||||
|
||||
- Make sure you have enabled the rest of the tests (see above).
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const repeatString = function() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = repeatString
|
||||
module.exports = repeatString;
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
const repeatString = require('./repeatString')
|
||||
|
||||
describe('repeatString', function() {
|
||||
it('repeats the string', function() {
|
||||
describe('repeatString', () => {
|
||||
test('repeats the string', () => {
|
||||
expect(repeatString('hey', 3)).toEqual('heyheyhey');
|
||||
});
|
||||
xit('repeats the string many times', function() {
|
||||
test.skip('repeats the string many times', () => {
|
||||
expect(repeatString('hey', 10)).toEqual('heyheyheyheyheyheyheyheyheyhey');
|
||||
});
|
||||
xit('repeats the string 1 times', function() {
|
||||
test.skip('repeats the string 1 times', () => {
|
||||
expect(repeatString('hey', 1)).toEqual('hey');
|
||||
});
|
||||
xit('repeats the string 0 times', function() {
|
||||
test.skip('repeats the string 0 times', () => {
|
||||
expect(repeatString('hey', 0)).toEqual('');
|
||||
});
|
||||
xit('returns ERROR with negative numbers', function() {
|
||||
test.skip('returns ERROR with negative numbers', () => {
|
||||
expect(repeatString('hey', -1)).toEqual('ERROR');
|
||||
});
|
||||
xit('repeats the string a random amount of times', function () {
|
||||
test.skip('repeats the string a random amount of times', function () {
|
||||
/*The number is generated by using Math.random to get a value from between
|
||||
0 to 1, when this is multiplied by 1000 and rounded down with Math.floor it
|
||||
equals a number between 0 to 999 (this number will change everytime you run
|
||||
|
@ -31,7 +31,7 @@ describe('repeatString', function() {
|
|||
was randomaly generated. */
|
||||
expect(repeatString('hey', number).match(/((hey))/g).length).toEqual(number);
|
||||
});
|
||||
xit('works with blank strings', function() {
|
||||
test.skip('works with blank strings', () => {
|
||||
expect(repeatString('', 10)).toEqual('');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Exercise 02 - Reverse a String.
|
||||
# Exercise 03 - Reverse a String
|
||||
|
||||
Pretty simple, write a function called `reverseString` that returns its input, reversed!
|
||||
|
||||
|
@ -6,10 +6,7 @@ Pretty simple, write a function called `reverseString` that returns its input, r
|
|||
reverseString('hello there') // returns 'ereht olleh'
|
||||
```
|
||||
|
||||
You will notice in this exercise that there are multiple tests, after making the first one pass, enable the others one by one by deleting the `x` in front of the `it()` function.
|
||||
|
||||
|
||||
|
||||
You will notice in this exercise that there are multiple tests, after making the first one pass, enable the others one by one by deleting the `.skip` in front the `test.skip()` function.
|
||||
|
||||
## Hints
|
||||
Strings in JavaScript cannot be reversed directly so you're going to have to split it into something else first.. do the reversal and then join it back together into a string.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const reverseString = function() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = reverseString
|
||||
module.exports = reverseString;
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
const reverseString = require('./reverseString')
|
||||
|
||||
describe('reverseString', function() {
|
||||
it('reverses single word', function() {
|
||||
describe('reverseString', () => {
|
||||
test('reverses single word', () => {
|
||||
expect(reverseString('hello')).toEqual('olleh');
|
||||
});
|
||||
|
||||
xit('reverses multiple words', function() {
|
||||
test.skip('reverses multiple words', () => {
|
||||
expect(reverseString('hello there')).toEqual('ereht olleh')
|
||||
})
|
||||
|
||||
xit('works with numbers and punctuation', function() {
|
||||
test.skip('works with numbers and punctuation', () => {
|
||||
expect(reverseString('123! abc!')).toEqual('!cba !321')
|
||||
})
|
||||
xit('works with blank strings', function() {
|
||||
test.skip('works with blank strings', () => {
|
||||
expect(reverseString('')).toEqual('')
|
||||
})
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const snakeCase = function() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = snakeCase
|
||||
module.exports = snakeCase;
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
const snakeCase = require('./snakeCase')
|
||||
|
||||
describe('snakeCase', function() {
|
||||
it('works with simple lowercased phrases', function() {
|
||||
describe('snakeCase', () => {
|
||||
test('works with simple lowercased phrases', () => {
|
||||
expect(snakeCase('hello world')).toEqual('hello_world');
|
||||
});
|
||||
xit('works with Caps and punctuation', function() {
|
||||
test.skip('works with Caps and punctuation', () => {
|
||||
expect(snakeCase('Hello, World???')).toEqual('hello_world');
|
||||
});
|
||||
xit('works with longer phrases', function() {
|
||||
test.skip('works with longer phrases', () => {
|
||||
expect(snakeCase('This is the song that never ends....')).toEqual('this_is_the_song_that_never_ends');
|
||||
});
|
||||
xit('works with camel case', function() {
|
||||
test.skip('works with camel case', () => {
|
||||
expect(snakeCase('snakeCase')).toEqual('snake_case');
|
||||
});
|
||||
xit('works with kebab case', function() {
|
||||
test.skip('works with kebab case', () => {
|
||||
expect(snakeCase('snake-case')).toEqual('snake_case');
|
||||
});
|
||||
xit('works with WTF case', function() {
|
||||
test.skip('works with WTF case', () => {
|
||||
expect(snakeCase('SnAkE..CaSe..Is..AwEsOmE')).toEqual('snake_case_is_awesome');
|
||||
});
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const sumAll = function() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = sumAll
|
||||
module.exports = sumAll;
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
const sumAll = require('./sumAll')
|
||||
|
||||
describe('sumAll', function() {
|
||||
it('sums numbers within the range', function() {
|
||||
describe('sumAll', () => {
|
||||
test('sums numbers within the range', () => {
|
||||
expect(sumAll(1, 4)).toEqual(10);
|
||||
});
|
||||
xit('works with large numbers', function() {
|
||||
test.skip('works with large numbers', () => {
|
||||
expect(sumAll(1, 4000)).toEqual(8002000);
|
||||
});
|
||||
xit('works with larger number first', function() {
|
||||
test.skip('works with larger number first', () => {
|
||||
expect(sumAll(123, 1)).toEqual(7626);
|
||||
});
|
||||
xit('returns ERROR with negative numbers', function() {
|
||||
test.skip('returns ERROR with negative numbers', () => {
|
||||
expect(sumAll(-10, 4)).toEqual('ERROR');
|
||||
});
|
||||
xit('returns ERROR with non-number parameters', function() {
|
||||
test.skip('returns ERROR with non-number parameters', () => {
|
||||
expect(sumAll(10, "90")).toEqual('ERROR');
|
||||
});
|
||||
xit('returns ERROR with non-number parameters', function() {
|
||||
test.skip('returns ERROR with non-number parameters', () => {
|
||||
expect(sumAll(10, [90, 1])).toEqual('ERROR');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Exercise 06 - tempConversion
|
||||
# Exercise 07 - tempConversion
|
||||
|
||||
Write two functions that convert temperatures from Fahrenheit to Celsius, and vice versa:
|
||||
```
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
const ftoc = function() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
const ctof = function() {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
ftoc,
|
||||
ctof
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
const {ftoc, ctof} = require('./tempConversion')
|
||||
|
||||
describe('ftoc', function() {
|
||||
it('works', function() {
|
||||
describe('ftoc', () => {
|
||||
test('works', () => {
|
||||
expect(ftoc(32)).toEqual(0);
|
||||
});
|
||||
xit('rounds to 1 decimal', function() {
|
||||
test.skip('rounds to 1 decimal', () => {
|
||||
expect(ftoc(100)).toEqual(37.8);
|
||||
});
|
||||
xit('works with negatives', function() {
|
||||
test.skip('works with negatives', () => {
|
||||
expect(ftoc(-100)).toEqual(-73.3);
|
||||
});
|
||||
});
|
||||
|
||||
describe('ctof', function() {
|
||||
xit('works', function() {
|
||||
describe('ctof', () => {
|
||||
test.skip('works', () => {
|
||||
expect(ctof(0)).toEqual(32);
|
||||
});
|
||||
xit('rounds to 1 decimal', function() {
|
||||
test.skip('rounds to 1 decimal', () => {
|
||||
expect(ctof(73.2)).toEqual(163.8);
|
||||
});
|
||||
xit('works with negatives', function() {
|
||||
test.skip('works with negatives', () => {
|
||||
expect(ctof(-10)).toEqual(14);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue