Skip to content

Commit 64d02f1

Browse files
authored
Merge pull request #6 from guillemontecinos/master
add fahrenheit2Celcius functions
2 parents 71ddb15 + 37c48ec commit 64d02f1

2 files changed

Lines changed: 25 additions & 2 deletions

File tree

sketch.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// adding something to see if it will force a build
2+
13
function sum(a, b) {
24
return a + b;
35
}
@@ -29,6 +31,10 @@ function anomalyCode(x) {
2931
return '5' + x - x;
3032
}
3133

34+
35+
function fahrenheit2Celcius(F) {
36+
return (F - 32) * 5 / 9;
37+
}
3238
function anomalyCode(x) {
3339
return '5' + x - x;
3440
}
@@ -51,6 +57,7 @@ module.exports = {
5157
sayHelloTo: sayHelloTo,
5258
answer: answer,
5359
anomalyCode: anomalyCode,
60+
fahrenheit2Celcius: fahrenheit2Celcius,
5461
power: power,
5562
nOfFibonacci: nOfFibonacci
5663
}

sketch.test.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
const { sum, sub, prod, digital_root, sum42, sayHelloTo, anomalyCode, power, nOfFibonacci } = require('./sketch');
1+
2+
const { sum, sub, prod, digital_root, sum42, sayHelloTo, anomalyCode, fahrenheit2Celcius, power, nOfFibonacci } = require('./sketch');
3+
4+
25
const fs = require("fs");
36
const path = require("path");
47
const fetch = require("node-fetch");
58

9+
610
// test('adds 1 + 2 to equal 3', () => {
711
// expect(sum(1, 2)).toBe(3);
812
// });
@@ -97,6 +101,18 @@ test('anomalyCode thousand should be 50000', () => {
97101
expect(anomalyCode(7891)).toBe(50000);
98102
})
99103

104+
test('fahrenheit2Celcius function exists', () => {
105+
expect(fahrenheit2Celcius(1)).toBeDefined();
106+
})
107+
108+
test('fahrenheit2Celcius 32 F should be 0 C', () => {
109+
expect(fahrenheit2Celcius(32)).toBe(0);
110+
})
111+
112+
test('fahrenheit2Celcius 50 F should be 10 C', () => {
113+
expect(fahrenheit2Celcius(50)).toBe(10);
114+
})
115+
100116
test('power of one number', () => {
101117
expect(power(2, 2)).toBe(4);
102118
})
@@ -128,4 +144,4 @@ it('tests url avaliability in README.md', async () => {
128144
let [testCount, testFunc] = testUrlInMarkdown("README.md");
129145
jest.setTimeout(testCount * 5000);
130146
return await testFunc();
131-
});
147+
});

0 commit comments

Comments
 (0)