Skip to content

Commit

Permalink
Fix/ tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rymatech committed May 15, 2019
1 parent a2661e6 commit e21db1a
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 25 deletions.
120 changes: 100 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
"scripts": {
"start": "node src/index.js",
"go": "nodemon src/index.js",
"test": "jest"
"test": "jest --watch"
},
"jest": {
"testEnvironment": "node"
},
"repository": {
"type": "git",
Expand All @@ -22,6 +25,7 @@
"bcrypt": "^3.0.6",
"env2": "^2.2.2",
"express": "^4.16.4",
"express-handlebars": "^3.1.0",
"pg": "^7.11.0",
"qs": "^6.7.0"
},
Expand Down
11 changes: 11 additions & 0 deletions tests/math.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const sum = (a, b) => a + b;
const mul = (a, b) => a * b;
const sub = (a, b) => a - b;
const div = (a, b) => a / b;

module.exports = {
sum,
mul,
sub,
div
};
21 changes: 17 additions & 4 deletions tests/math.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
const sum = (a, b) => a + b;
const mul = (a, b) => a * b;
const sub = (a, b) => a - b;
const div = (a, b) => a / b;
const { sum, mul, sub, div } = require("./math");

test("Adding 1 + 1 equals 2", () => {
expect(sum(1, 1)).toBe(2);
Expand All @@ -15,3 +12,19 @@ test("Subtracting 1 - 1 equals 0", () => {
test("Dividing 1 / 1 equals 1", () => {
expect(div(1, 1)).toBe(1);
});

const fahrenheitToCelsius = temp => {
return (temp - 32) / 1.8;
};

const celsiusToFahrenheit = temp => {
return temp * 1.8 + 32;
};

test("Should convert 32 F to 0 C", () => {
expect(fahrenheitToCelsius(32)).toBe(0);
});

test("Should convert 0 C to 32 F", () => {
expect(celsiusToFahrenheit(0)).toBe(32);
});
Empty file added tests/test.env
Empty file.

0 comments on commit e21db1a

Please sign in to comment.