Merge pull request #145 from TheOdinProject/fix/revert-jest
Fix/revert jest
This commit is contained in:
commit
ac73d925a3
|
@ -1,6 +0,0 @@
|
|||
module.exports = {
|
||||
"extends": "airbnb-base",
|
||||
"plugins": [
|
||||
"import"
|
||||
]
|
||||
};
|
|
@ -1,6 +1 @@
|
|||
.vscode
|
||||
node_modules/
|
||||
package-lock.json
|
||||
package.json
|
||||
.eslintrc
|
||||
.DS_Store
|
||||
.vscode
|
|
@ -9,12 +9,10 @@ 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. 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).
|
||||
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/free-pro-team@latest/github/creating-cloning-and-archiving-repositories/duplicating-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 `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 will 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.
|
||||
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.
|
||||
|
||||
The first exercise, `helloWorld`, will walk you through the process in-depth.
|
||||
|
||||
|
|
Binary file not shown.
|
@ -1,5 +1,5 @@
|
|||
const caesar = function() {
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = caesar;
|
||||
module.exports = caesar
|
||||
|
|
|
@ -1,23 +1,25 @@
|
|||
const caesar = require("./caesar");
|
||||
const caesar = require('./caesar')
|
||||
|
||||
test('works with single letters', () => {
|
||||
expect(caesar('A', 1)).toBe('B');
|
||||
});
|
||||
test.skip('works with words', () => {
|
||||
expect(caesar('Aaa', 1)).toBe('Bbb');
|
||||
});
|
||||
test.skip('works with phrases', () => {
|
||||
expect(caesar('Hello, World!', 5)).toBe('Mjqqt, Btwqi!');
|
||||
});
|
||||
test.skip('works with negative shift', () => {
|
||||
expect(caesar('Mjqqt, Btwqi!', -5)).toBe('Hello, World!');
|
||||
});
|
||||
test.skip('wraps', () => {
|
||||
expect(caesar('Z', 1)).toBe('A');
|
||||
});
|
||||
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!');
|
||||
describe('caesar', function() {
|
||||
it('works with single letters', function() {
|
||||
expect(caesar('A', 1)).toEqual('B');
|
||||
});
|
||||
xit('works with words', function() {
|
||||
expect(caesar('Aaa', 1)).toEqual('Bbb');
|
||||
});
|
||||
xit('works with phrases', function() {
|
||||
expect(caesar('Hello, World!', 5)).toEqual('Mjqqt, Btwqi!');
|
||||
});
|
||||
xit('works with negative shift', function() {
|
||||
expect(caesar('Mjqqt, Btwqi!', -5)).toEqual('Hello, World!');
|
||||
});
|
||||
xit('wraps', function() {
|
||||
expect(caesar('Z', 1)).toEqual('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!');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
const add = function() {
|
||||
|
||||
function add () {
|
||||
|
||||
}
|
||||
|
||||
const subtract = function() {
|
||||
|
||||
function subtract () {
|
||||
|
||||
}
|
||||
|
||||
const sum = function() {
|
||||
|
||||
function sum () {
|
||||
|
||||
}
|
||||
|
||||
const multiply = function() {
|
||||
|
||||
function multiply () {
|
||||
|
||||
}
|
||||
|
||||
const power = function() {
|
||||
|
||||
function power() {
|
||||
|
||||
}
|
||||
|
||||
const factorial = function() {
|
||||
|
||||
function factorial() {
|
||||
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
@ -28,5 +28,5 @@ module.exports = {
|
|||
sum,
|
||||
multiply,
|
||||
power,
|
||||
factorial
|
||||
factorial,
|
||||
};
|
||||
|
|
|
@ -1,77 +1,77 @@
|
|||
const calculator = require ('./calculator.js');
|
||||
|
||||
describe('add', () => {
|
||||
test('adds 0 and 0', () => {
|
||||
expect(calculator.add(0,0)).toBe(0);
|
||||
describe('add', function() {
|
||||
it('adds 0 and 0', function() {
|
||||
expect(calculator.add(0,0)).toEqual(0);
|
||||
});
|
||||
|
||||
test('adds 2 and 2', () => {
|
||||
expect(calculator.add(2,2)).toBe(4);
|
||||
xit('adds 2 and 2', function() {
|
||||
expect(calculator.add(2,2)).toEqual(4);
|
||||
});
|
||||
|
||||
test('adds positive numbers', () => {
|
||||
expect(calculator.add(2,6)).toBe(8);
|
||||
xit('adds positive numbers', function() {
|
||||
expect(calculator.add(2,6)).toEqual(8);
|
||||
});
|
||||
});
|
||||
|
||||
describe('subtract', () => {
|
||||
test('subtracts numbers', () => {
|
||||
expect(calculator.subtract(10,4)).toBe(6);
|
||||
describe('subtract', function() {
|
||||
xit('subtracts numbers', function() {
|
||||
expect(calculator.subtract(10,4)).toEqual(6);
|
||||
});
|
||||
});
|
||||
|
||||
describe('sum', () => {
|
||||
test('computes the sum of an empty array', () => {
|
||||
expect(calculator.sum([])).toBe(0);
|
||||
describe('sum', function() {
|
||||
xit('computes the sum of an empty array', function() {
|
||||
expect(calculator.sum([])).toEqual(0);
|
||||
});
|
||||
|
||||
test('computes the sum of an array of one number', () => {
|
||||
expect(calculator.sum([7])).toBe(7);
|
||||
xit('computes the sum of an array of one number', function() {
|
||||
expect(calculator.sum([7])).toEqual(7);
|
||||
});
|
||||
|
||||
test('computes the sum of an array of two numbers', () => {
|
||||
expect(calculator.sum([7,11])).toBe(18);
|
||||
xit('computes the sum of an array of two numbers', function() {
|
||||
expect(calculator.sum([7,11])).toEqual(18);
|
||||
});
|
||||
|
||||
test('computes the sum of an array of many numbers', () => {
|
||||
expect(calculator.sum([1,3,5,7,9])).toBe(25);
|
||||
xit('computes the sum of an array of many numbers', function() {
|
||||
expect(calculator.sum([1,3,5,7,9])).toEqual(25);
|
||||
});
|
||||
});
|
||||
|
||||
describe('multiply', () => {
|
||||
test('multiplies two numbers', () => {
|
||||
expect(calculator.multiply([2,4])).toBe(8);
|
||||
describe('multiply', function() {
|
||||
xit('multiplies two numbers', function() {
|
||||
expect(calculator.multiply([2,4])).toEqual(8);
|
||||
});
|
||||
|
||||
test('multiplies several numbers', () => {
|
||||
expect(calculator.multiply([2,4,6,8,10,12,14])).toBe(645120);
|
||||
xit('multiplies several numbers', function() {
|
||||
expect(calculator.multiply([2,4,6,8,10,12,14])).toEqual(645120);
|
||||
});
|
||||
});
|
||||
|
||||
describe('power', () => {
|
||||
test('raises one number to the power of another number', () => {
|
||||
expect(calculator.power(4,3)).toBe(64); // 4 to third power is 64
|
||||
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('factorial', () => {
|
||||
test.skip('computes the factorial of 0', () => {
|
||||
expect(calculator.factorial(0)).toBe(1); // 0! = 1
|
||||
describe('factorial', function() {
|
||||
xit('computes the factorial of 0', function() {
|
||||
expect(calculator.factorial(0)).toEqual(1); // 0! = 1
|
||||
});
|
||||
|
||||
test.skip('computes the factorial of 1', () => {
|
||||
expect(calculator.factorial(1)).toBe(1);
|
||||
xit('computes the factorial of 1', function() {
|
||||
expect(calculator.factorial(1)).toEqual(1);
|
||||
});
|
||||
|
||||
test.skip('computes the factorial of 2', () => {
|
||||
expect(calculator.factorial(2)).toBe(2);
|
||||
xit('computes the factorial of 2', function() {
|
||||
expect(calculator.factorial(2)).toEqual(2);
|
||||
});
|
||||
|
||||
test.skip('computes the factorial of 5', () => {
|
||||
expect(calculator.factorial(5)).toBe(120);
|
||||
xit('computes the factorial of 5', function() {
|
||||
expect(calculator.factorial(5)).toEqual(120);
|
||||
});
|
||||
|
||||
test.skip('computes the factorial of 10', () => {
|
||||
expect(calculator.factorial(10)).toBe(3628800);
|
||||
xit('computes the factorial of 10', function() {
|
||||
expect(calculator.factorial(10)).toEqual(3628800);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const fibonacci = function() {
|
||||
const fibonacci = function () {};
|
||||
|
||||
}
|
||||
|
||||
module.exports = fibonacci;
|
||||
module.exports = fibonacci
|
||||
|
|
|
@ -1,31 +1,31 @@
|
|||
const fibonacci = require("./fibonacci");
|
||||
const fibonacci = require('./fibonacci')
|
||||
|
||||
describe('fibonacci', () => {
|
||||
test('4th fibonacci number is 3', () => {
|
||||
expect(fibonacci(4)).toBe(3);
|
||||
describe('fibonacci', function() {
|
||||
it('works', function() {
|
||||
expect(fibonacci(4)).toEqual(3);
|
||||
});
|
||||
test.skip('6th fibonacci number is 8', () => {
|
||||
expect(fibonacci(6)).toBe(8);
|
||||
xit('works', function() {
|
||||
expect(fibonacci(6)).toEqual(8);
|
||||
});
|
||||
test.skip('10th fibonacci number is 55', () => {
|
||||
expect(fibonacci(10)).toBe(55);
|
||||
xit('works', function() {
|
||||
expect(fibonacci(10)).toEqual(55);
|
||||
});
|
||||
test.skip('15th fibonacci number is 610', () => {
|
||||
expect(fibonacci(15)).toBe(610);
|
||||
xit('works', function() {
|
||||
expect(fibonacci(15)).toEqual(610);
|
||||
});
|
||||
test.skip('25th fibonacci number is 75025', () => {
|
||||
expect(fibonacci(25)).toBe(75025);
|
||||
xit('works', function() {
|
||||
expect(fibonacci(25)).toEqual(75025);
|
||||
});
|
||||
test.skip('doesn\'t accept negatives', () => {
|
||||
expect(fibonacci(-25)).toBe("OOPS");
|
||||
xit('doesn\'t accept negatives', function() {
|
||||
expect(fibonacci(-25)).toEqual("OOPS");
|
||||
});
|
||||
test.skip('DOES accept strings', () => {
|
||||
expect(fibonacci("1")).toBe(1);
|
||||
xit('DOES accept strings', function() {
|
||||
expect(fibonacci("1")).toEqual(1);
|
||||
});
|
||||
test.skip('DOES accept strings', () => {
|
||||
expect(fibonacci("2")).toBe(1);
|
||||
xit('DOES accept strings', function() {
|
||||
expect(fibonacci("2")).toEqual(1);
|
||||
});
|
||||
test.skip('DOES accept strings', () => {
|
||||
expect(fibonacci("8")).toBe(21);
|
||||
xit('DOES accept strings', function() {
|
||||
expect(fibonacci("8")).toEqual(21);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -7,4 +7,3 @@ given an array of objects representing people with a birth and death year, retur
|
|||
- 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,3 @@
|
|||
const findTheOldest = function() {
|
||||
|
||||
let findTheOldest = function() {
|
||||
}
|
||||
|
||||
module.exports = findTheOldest
|
||||
module.exports = findTheOldest;
|
||||
|
|
|
@ -1,64 +1,62 @@
|
|||
const findTheOldest = require('./findTheOldest')
|
||||
let findTheOldest = require('./findTheOldest')
|
||||
|
||||
describe('findTheOldest', () => {
|
||||
test('finds the oldest person!', () => {
|
||||
describe('findTheOldest', function() {
|
||||
it('finds the oldest person!', function() {
|
||||
const people = [
|
||||
{
|
||||
name: 'Carly',
|
||||
name: "Carly",
|
||||
yearOfBirth: 1942,
|
||||
yearOfDeath: 1970,
|
||||
},
|
||||
{
|
||||
name: 'Ray',
|
||||
name: "Ray",
|
||||
yearOfBirth: 1962,
|
||||
yearOfDeath: 2011
|
||||
yearOfDeath: 2011,
|
||||
},
|
||||
{
|
||||
name: 'Jane',
|
||||
name: "Jane",
|
||||
yearOfBirth: 1912,
|
||||
yearOfDeath: 1941
|
||||
yearOfDeath: 1941,
|
||||
},
|
||||
]
|
||||
expect(findTheOldest(people).name).toBe('Ray');
|
||||
expect(findTheOldest(people).name).toEqual('Ray');
|
||||
});
|
||||
test.skip('finds the oldest person if someone is still living', () => {
|
||||
xit('finds the oldest person if someone is still living', function() {
|
||||
const people = [
|
||||
{
|
||||
name: 'Carly',
|
||||
name: "Carly",
|
||||
yearOfBirth: 2018,
|
||||
},
|
||||
{
|
||||
name: 'Ray',
|
||||
name: "Ray",
|
||||
yearOfBirth: 1962,
|
||||
yearOfDeath: 2011
|
||||
yearOfDeath: 2011,
|
||||
},
|
||||
{
|
||||
name: 'Jane',
|
||||
name: "Jane",
|
||||
yearOfBirth: 1912,
|
||||
yearOfDeath: 1941
|
||||
yearOfDeath: 1941,
|
||||
},
|
||||
]
|
||||
expect(findTheOldest(people).name).toBe('Ray');
|
||||
expect(findTheOldest(people).name).toEqual('Ray');
|
||||
});
|
||||
test.skip('finds the oldest person if the OLDEST is still living', () => {
|
||||
xit('finds the oldest person if the OLDEST is still living', function() {
|
||||
const people = [
|
||||
{
|
||||
name: 'Carly',
|
||||
name: "Carly",
|
||||
yearOfBirth: 1066,
|
||||
},
|
||||
{
|
||||
name: 'Ray',
|
||||
name: "Ray",
|
||||
yearOfBirth: 1962,
|
||||
yearOfDeath: 2011
|
||||
yearOfDeath: 2011,
|
||||
},
|
||||
{
|
||||
name: 'Jane',
|
||||
name: "Jane",
|
||||
yearOfBirth: 1912,
|
||||
yearOfDeath: 1941
|
||||
yearOfDeath: 1941,
|
||||
},
|
||||
]
|
||||
expect(findTheOldest(people).name).toBe('Carly');
|
||||
expect(findTheOldest(people).name).toEqual('Carly');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
"name": "generator-exercise",
|
||||
"version": "0.0.0",
|
||||
"description": "generates boilerplate for The Odin Project exercises",
|
||||
"homepage": "theodinproject.com",
|
||||
"author": {
|
||||
"name": "Cody Loyd",
|
||||
"email": "codyloyd@gmail.com",
|
||||
"url": "codyloyd.com"
|
||||
},
|
||||
"files": [
|
||||
"generators"
|
||||
],
|
||||
"main": "generators/index.js",
|
||||
"keywords": [
|
||||
"lame",
|
||||
"yeoman-generator"
|
||||
],
|
||||
"devDependencies": {
|
||||
"yeoman-test": "^1.6.0",
|
||||
"yeoman-assert": "^3.0.0",
|
||||
"nsp": "^2.6.3",
|
||||
"eslint": "^4.1.0",
|
||||
"eslint-config-xo-space": "^0.16.0",
|
||||
"jest": "^19.0.2",
|
||||
"jest-cli": "^20.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"chalk": "^1.1.3",
|
||||
"extend": "^3.0.2",
|
||||
"yeoman-generator": "^1.0.0",
|
||||
"yosay": "^2.0.0"
|
||||
},
|
||||
"jest": {
|
||||
"testEnvironment": "node"
|
||||
},
|
||||
"scripts": {
|
||||
"prepublish": "nsp check",
|
||||
"pretest": "eslint . --fix",
|
||||
"test": "jest"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "xo-space",
|
||||
"env": {
|
||||
"jest": true,
|
||||
"node": true
|
||||
}
|
||||
},
|
||||
"repository": "git@github.com:TheOdinProject/javascript-exercises.git",
|
||||
"license": "MIT"
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
# GET THE TITLES!
|
||||
# Get the Titles!
|
||||
|
||||
You are given an array of objects that represent books with an author and a title that looks like this:
|
||||
|
||||
|
@ -24,4 +24,3 @@ getTheTitles(books) // ['Book','Book2']
|
|||
## Hints
|
||||
|
||||
- You should use a built-in javascript method to do most of the work for you!
|
||||
<Paste>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
var getTheTitles = function() {
|
||||
const getTheTitles = function() {
|
||||
|
||||
}
|
||||
|
||||
module.exports = getTheTitles
|
||||
module.exports = getTheTitles;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
const getTheTitles = require('./getTheTitles')
|
||||
let getTheTitles = require('./getTheTitles')
|
||||
|
||||
describe('getTheTitles', () => {
|
||||
describe('getTheTitles', function() {
|
||||
const books = [
|
||||
{
|
||||
title: 'Book',
|
||||
|
@ -12,8 +12,7 @@ describe('getTheTitles', () => {
|
|||
}
|
||||
]
|
||||
|
||||
test('gets titles', () => {
|
||||
expect(getTheTitles(books)).toBe(['Book','Book2']);
|
||||
it('gets titles', function() {
|
||||
expect(getTheTitles(books)).toEqual(['Book','Book2']);
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
var helloWorld = function() {
|
||||
const helloWorld = function() {
|
||||
return ''
|
||||
}
|
||||
|
||||
module.exports = helloWorld;
|
||||
module.exports = helloWorld
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
const helloWorld = require('./helloWorld');
|
||||
|
||||
test('says "Hello, World!"', function() {
|
||||
expect(helloWorld()).toBe("Hello, World!");
|
||||
});
|
||||
describe('Hello World', function() {
|
||||
it('says hello world', function() {
|
||||
expect(helloWorld()).toEqual('Hello, World!');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
Create a function that determines whether or not a given year is a leap year. Leap years are determined by the following rules:
|
||||
|
||||
>There is a leap year every year whose number is perfectly divisible by four - except for years evenly divisible by 100, which are not leap years unless evenly divisible by 400. The second part of the rule affects century years. For example; the century years 1600 and 2000 are leap years, but the century years 1700, 1800, and 1900 are not.
|
||||
> Leap years are years divisible by four (like 1984 and 2004). However, years divisible by 100 are not leap years (such as 1800 and 1900) unless they are divisible by 400 (like 1600 and 2000, which were in fact leap years). (Yes, it's all pretty confusing)
|
||||
>
|
||||
> -- <cite>[Learn to Program](https://pine.fm/LearnToProgram/chap_06.html) by Chris Pine</cite>
|
||||
|
||||
```javascript
|
||||
leapYears(2000) // is a leap year: returns true
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var leapYears = function() {
|
||||
const leapYears = function() {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
const leapYears = require('./leapYears')
|
||||
|
||||
describe('leapYears', () => {
|
||||
test('works with non century years', () => {
|
||||
expect(leapYears(1996)).toBe(true);
|
||||
describe('leapYears', function() {
|
||||
it('works with non century years', function() {
|
||||
expect(leapYears(1996)).toEqual(true);
|
||||
});
|
||||
test.skip('works with non century years', () => {
|
||||
expect(leapYears(1997)).toBe(false);
|
||||
xit('works with non century years', function() {
|
||||
expect(leapYears(1997)).toEqual(false);
|
||||
});
|
||||
test.skip('works with ridiculously futuristic non century years', () => {
|
||||
expect(leapYears(34992)).toBe(true);
|
||||
xit('works with ridiculously futuristic non century years', function() {
|
||||
expect(leapYears(34992)).toEqual(true);
|
||||
});
|
||||
test.skip('works with century years', () => {
|
||||
expect(leapYears(1900)).toBe(false);
|
||||
xit('works with century years', function() {
|
||||
expect(leapYears(1900)).toEqual(false);
|
||||
});
|
||||
test.skip('works with century years', () => {
|
||||
expect(leapYears(1600)).toBe(true);
|
||||
xit('works with century years', function() {
|
||||
expect(leapYears(1600)).toEqual(true);
|
||||
});
|
||||
test.skip('works with century years', () => {
|
||||
expect(leapYears(700)).toBe(false);
|
||||
xit('works with century years', function() {
|
||||
expect(leapYears(700)).toEqual(false);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
const palindromes = function() {
|
||||
const palindromes = function () {};
|
||||
|
||||
}
|
||||
|
||||
module.exports = palindromes;
|
||||
module.exports = palindromes
|
||||
|
|
|
@ -1,23 +1,22 @@
|
|||
const palindromes = require("./palindromes");
|
||||
const palindromes = require('./palindromes')
|
||||
|
||||
describe('palindromes', () => {
|
||||
test('works with single words', () => {
|
||||
expect(palindromes('racecar')).toBe(true);
|
||||
describe('palindromes', function() {
|
||||
it('works with single words', function() {
|
||||
expect(palindromes('racecar')).toEqual(true);
|
||||
});
|
||||
test.skip('works with punctuation ', () => {
|
||||
expect(palindromes('racecar!')).toBe(true);
|
||||
xit('works with punctuation ', function() {
|
||||
expect(palindromes('racecar!')).toEqual(true);
|
||||
});
|
||||
test.skip('works with upper-case letters ', () => {
|
||||
expect(palindromes('Racecar!')).toBe(true);
|
||||
xit('works with upper-case letters ', function() {
|
||||
expect(palindromes('Racecar!')).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('A car, a man, a maraca.')).toEqual(true);
|
||||
});
|
||||
test.skip('works with multiple words', () => {
|
||||
expect(palindromes('Animal loots foliated detail of stool lamina.')).toBe(true);
|
||||
xit('works with multiple words', function() {
|
||||
expect(palindromes('Animal loots foliated detail of stool lamina.')).toEqual(true);
|
||||
});
|
||||
test.skip('doesn\'t just always return true', () => {
|
||||
expect(palindromes('ZZZZ car, a man, a maraca.')).toBe(false);
|
||||
xit('doesn\'t just always return true', function() {
|
||||
expect(palindromes('ZZZZ car, a man, a maraca.')).toEqual(false);
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
const translate = function() {
|
||||
|
||||
function translate() {
|
||||
// body...
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
translate
|
||||
}
|
||||
|
||||
module.exports = translate
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
const expect = require("expect");
|
||||
|
||||
// Topics
|
||||
|
||||
// * modules
|
||||
|
@ -7,11 +5,11 @@ const expect = require("expect");
|
|||
|
||||
// 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.
|
||||
// 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 test to the end of the word, and then 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.)
|
||||
|
||||
|
@ -19,48 +17,48 @@ const expect = require("expect");
|
|||
|
||||
const pigLatin = require("./pigLatin.js");
|
||||
|
||||
describe('translate', () => {
|
||||
test('translates a word beginning with a vowel', () => {
|
||||
describe('#translate', function() {
|
||||
it('translates a word beginning with a vowel', function() {
|
||||
s = pigLatin.translate("apple");
|
||||
expect(s).toBe('appleay');
|
||||
expect(s).toEqual('appleay');
|
||||
});
|
||||
|
||||
test.skip('translates a word beginning with a consonant', () => {
|
||||
xit('translates a word beginning with a consonant', function() {
|
||||
s = pigLatin.translate("banana");
|
||||
expect(s).toBe("ananabay");
|
||||
expect(s).toEqual("ananabay");
|
||||
});
|
||||
|
||||
test.skip('translates a word beginning with two consonants', () => {
|
||||
xit('translates a word beginning with two consonants', function() {
|
||||
s = pigLatin.translate("cherry");
|
||||
expect(s).toBe('errychay');
|
||||
expect(s).toEqual('errychay');
|
||||
});
|
||||
|
||||
test.skip('translates two words', () => {
|
||||
xit('translates two words', function() {
|
||||
s = pigLatin.translate("eat pie");
|
||||
expect(s).toBe('eatay iepay');
|
||||
expect(s).toEqual('eatay iepay');
|
||||
});
|
||||
|
||||
test.skip('translates a word beginning with three consonants', () => {
|
||||
expect(pigLatin.translate("three")).toBe("eethray");
|
||||
xit('translates a word beginning with three consonants', function() {
|
||||
expect(pigLatin.translate("three")).toEqual("eethray");
|
||||
});
|
||||
|
||||
test.skip('counts "sch" as a single phoneme', () => {
|
||||
xit('counts "sch" as a single phoneme', function() {
|
||||
s = pigLatin.translate("school");
|
||||
expect(s).toBe("oolschay");
|
||||
expect(s).toEqual("oolschay");
|
||||
});
|
||||
|
||||
test.skip('counts "qu" as a single phoneme', () => {
|
||||
xit('counts "qu" as a single phoneme', function() {
|
||||
s = pigLatin.translate("quiet");
|
||||
expect(s).toBe("ietquay");
|
||||
expect(s).toEqual("ietquay");
|
||||
});
|
||||
|
||||
test.skip('counts "qu" as a consonant even when its preceded by a consonant', () => {
|
||||
xit('counts "qu" as a consonant even when its preceded by a consonant', function() {
|
||||
s = pigLatin.translate("square");
|
||||
expect(s).toBe("aresquay");
|
||||
expect(s).toEqual("aresquay");
|
||||
});
|
||||
|
||||
test.skip('translates many words', () => {
|
||||
xit('translates many words', function() {
|
||||
s = pigLatin.translate("the quick brown fox");
|
||||
expect(s).toBe("ethay ickquay ownbray oxfay");
|
||||
expect(s).toEqual("ethay ickquay ownbray oxfay");
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const removeFromArray = function () {
|
||||
const removeFromArray = function() {
|
||||
|
||||
}
|
||||
|
||||
module.exports = removeFromArray;
|
||||
module.exports = removeFromArray
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
const removeFromArray = require('./removeFromArray')
|
||||
|
||||
describe('removeFromArray', () => {
|
||||
test('removes a single value', () => {
|
||||
expect(removeFromArray([1, 2, 3, 4], 3)).toBe([1, 2, 4]);
|
||||
describe('removeFromArray', function() {
|
||||
it('removes a single value', function() {
|
||||
expect(removeFromArray([1, 2, 3, 4], 3)).toEqual([1, 2, 4]);
|
||||
});
|
||||
test.skip('removes multiple values', () => {
|
||||
expect(removeFromArray([1, 2, 3, 4], 3, 2)).toBe([1, 4]);
|
||||
xit('removes multiple values', function() {
|
||||
expect(removeFromArray([1, 2, 3, 4], 3, 2)).toEqual([1, 4]);
|
||||
});
|
||||
test.skip('ignores non present values', () => {
|
||||
expect(removeFromArray([1, 2, 3, 4], 7, "tacos")).toBe([1, 2, 3, 4]);
|
||||
xit('ignores non present values', function() {
|
||||
expect(removeFromArray([1, 2, 3, 4], 7, "tacos")).toEqual([1, 2, 3, 4]);
|
||||
});
|
||||
test.skip('ignores non present values, but still works', () => {
|
||||
expect(removeFromArray([1, 2, 3, 4], 7, 2)).toBe([1, 3, 4]);
|
||||
xit('ignores non present values, but still works', function() {
|
||||
expect(removeFromArray([1, 2, 3, 4], 7, 2)).toEqual([1, 3, 4]);
|
||||
});
|
||||
test.skip('can remove all values', () => {
|
||||
expect(removeFromArray([1, 2, 3, 4], 1, 2, 3, 4)).toBe([]);
|
||||
xit('can remove all values', function() {
|
||||
expect(removeFromArray([1, 2, 3, 4], 1, 2, 3, 4)).toEqual([]);
|
||||
});
|
||||
test.skip('works with strings', () => {
|
||||
expect(removeFromArray(["hey", 2, 3, "ho"], "hey", 3)).toBe([2, "ho"]);
|
||||
xit('works with strings', function() {
|
||||
expect(removeFromArray(["hey", 2, 3, "ho"], "hey", 3)).toEqual([2, "ho"]);
|
||||
});
|
||||
test.skip('only removes same type', () => {
|
||||
expect(removeFromArray([1, 2, 3], "1", 3)).toBe([1, 2]);
|
||||
xit('only removes same type', function() {
|
||||
expect(removeFromArray([1, 2, 3], "1", 3)).toEqual([1, 2]);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var repeatString = function() {
|
||||
const repeatString = function() {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
const expect = require('expect');const repeatString = require('./repeatString')
|
||||
const repeatString = require('./repeatString')
|
||||
|
||||
describe('repeatString', function() {
|
||||
it('repeats the string', function() {
|
||||
expect(repeatString('hey', 3)).toEqual('heyheyhey');
|
||||
});
|
||||
it('repeats the string many times', function() {
|
||||
xit('repeats the string many times', function() {
|
||||
expect(repeatString('hey', 10)).toEqual('heyheyheyheyheyheyheyheyheyhey');
|
||||
});
|
||||
it('repeats the string 1 times', function() {
|
||||
xit('repeats the string 1 times', function() {
|
||||
expect(repeatString('hey', 1)).toEqual('hey');
|
||||
});
|
||||
it('repeats the string 0 times', function() {
|
||||
xit('repeats the string 0 times', function() {
|
||||
expect(repeatString('hey', 0)).toEqual('');
|
||||
});
|
||||
it('returns ERROR with negative numbers', function() {
|
||||
xit('returns ERROR with negative numbers', function() {
|
||||
expect(repeatString('hey', -1)).toEqual('ERROR');
|
||||
});
|
||||
xit('repeats the string a random amount of times', function () {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var reverseString = function() {
|
||||
const reverseString = function() {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
const expect = require('expect');const reverseString = require('./reverseString')
|
||||
const reverseString = require('./reverseString')
|
||||
|
||||
describe('reverseString', function() {
|
||||
it('reverses single word', function() {
|
||||
expect(reverseString('hello')).toEqual('olleh');
|
||||
});
|
||||
|
||||
it('reverses multiple words', function() {
|
||||
xit('reverses multiple words', function() {
|
||||
expect(reverseString('hello there')).toEqual('ereht olleh')
|
||||
})
|
||||
|
||||
it('works with numbers and punctuation', function() {
|
||||
xit('works with numbers and punctuation', function() {
|
||||
expect(reverseString('123! abc!')).toEqual('!cba !321')
|
||||
})
|
||||
xit('works with blank strings', function() {
|
||||
expect(reverseString('')).toEqual('')
|
||||
})
|
||||
});
|
||||
|
|
|
@ -2,4 +2,4 @@ const snakeCase = function() {
|
|||
|
||||
}
|
||||
|
||||
module.exports = snakeCase;
|
||||
module.exports = snakeCase
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
const snakeCase = require('./snakeCase')
|
||||
|
||||
describe("snakeCase", () => {
|
||||
it("works with simple lowercased phrases", () => {
|
||||
describe("snakeCase", function () {
|
||||
it("works with simple lowercased phrases", function () {
|
||||
expect(snakeCase("hello world")).toEqual("hello_world");
|
||||
});
|
||||
it("works with Caps and punctuation", () => {
|
||||
xit("works with Caps and punctuation", function () {
|
||||
expect(snakeCase("Hello, World???")).toEqual("hello_world");
|
||||
});
|
||||
it("works with longer phrases", () => {
|
||||
xit("works with longer phrases", function () {
|
||||
expect(snakeCase("This is the song that never ends....")).toEqual(
|
||||
"this_is_the_song_that_never_ends"
|
||||
);
|
||||
});
|
||||
it("works with camel case", () => {
|
||||
xit("works with camel case", function () {
|
||||
expect(snakeCase("snakeCase")).toEqual("snake_case");
|
||||
});
|
||||
it("works with kebab case", () => {
|
||||
xit("works with kebab case", function () {
|
||||
expect(snakeCase("snake-case")).toEqual("snake_case");
|
||||
});
|
||||
it("works with WTF case", () => {
|
||||
xit("works with WTF case", function () {
|
||||
expect(snakeCase("SnAkE..CaSe..Is..AwEsOmE")).toEqual(
|
||||
"snake_case_is_awesome"
|
||||
);
|
||||
|
|
|
@ -2,4 +2,4 @@ const sumAll = function() {
|
|||
|
||||
}
|
||||
|
||||
module.exports = sumAll;
|
||||
module.exports = sumAll
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
const sumAll = require("./sumAll");
|
||||
const sumAll = require('./sumAll')
|
||||
|
||||
describe("sumAll", () => {
|
||||
it("sums numbers within the range", () => {
|
||||
describe("sumAll", function () {
|
||||
it("sums numbers within the range", function () {
|
||||
expect(sumAll(1, 4)).toEqual(10);
|
||||
});
|
||||
it("works with large numbers", () => {
|
||||
xit("works with large numbers", function () {
|
||||
expect(sumAll(1, 4000)).toEqual(8002000);
|
||||
});
|
||||
it("works with larger number first", () => {
|
||||
xit("works with larger number first", function () {
|
||||
expect(sumAll(123, 1)).toEqual(7626);
|
||||
});
|
||||
it("returns ERROR with negative numbers", () => {
|
||||
xit("returns ERROR with negative numbers", function () {
|
||||
expect(sumAll(-10, 4)).toEqual("ERROR");
|
||||
});
|
||||
it("returns ERROR with non-number parameters", () => {
|
||||
xit("returns ERROR with non-number parameters", function () {
|
||||
expect(sumAll(10, "90")).toEqual("ERROR");
|
||||
});
|
||||
it("returns ERROR with non-number parameters", () => {
|
||||
xit("returns ERROR with non-number parameters", function () {
|
||||
expect(sumAll(10, [90, 1])).toEqual("ERROR");
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
var ftoc = function() {
|
||||
const ftoc = function() {
|
||||
|
||||
}
|
||||
|
||||
var ctof = function() {
|
||||
const ctof = function() {
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
const expect = require('expect');const {ftoc, ctof} = require('./tempConversion')
|
||||
const {ftoc, ctof} = require('./tempConversion')
|
||||
|
||||
describe('ftoc', function() {
|
||||
it('works', function() {
|
||||
expect(ftoc(32)).toEqual(0);
|
||||
});
|
||||
it('rounds to 1 decimal', function() {
|
||||
xit('rounds to 1 decimal', function() {
|
||||
expect(ftoc(100)).toEqual(37.8);
|
||||
});
|
||||
it('works with negatives', function() {
|
||||
xit('works with negatives', function() {
|
||||
expect(ftoc(-100)).toEqual(-73.3);
|
||||
});
|
||||
});
|
||||
|
||||
describe('ctof', function() {
|
||||
it('works', function() {
|
||||
xit('works', function() {
|
||||
expect(ctof(0)).toEqual(32);
|
||||
});
|
||||
it('rounds to 1 decimal', function() {
|
||||
xit('rounds to 1 decimal', function() {
|
||||
expect(ctof(73.2)).toEqual(163.8);
|
||||
});
|
||||
it('works with negatives', function() {
|
||||
xit('works with negatives', function() {
|
||||
expect(ctof(-10)).toEqual(14);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue