Merge pull request #764 from evyatarmeged/master
[FEATURE] add celsiusToFahrenheit and fahrenheitToCelsius
This commit is contained in:
2
test/celsiusToFahrenheit/celsiusToFahrenheit.js
Normal file
2
test/celsiusToFahrenheit/celsiusToFahrenheit.js
Normal file
@ -0,0 +1,2 @@
|
||||
const celsiusToFahrenheit = degrees => 1.8 * degrees + 32;
|
||||
module.exports = celsiusToFahrenheit;
|
||||
26
test/celsiusToFahrenheit/celsiusToFahrenheit.test.js
Normal file
26
test/celsiusToFahrenheit/celsiusToFahrenheit.test.js
Normal file
@ -0,0 +1,26 @@
|
||||
const expect = require('expect');
|
||||
const celsiusToFahrenheit = require('./celsiusToFahrenheit.js');
|
||||
|
||||
test('celsiusToFahrenheit is a Function', () => {
|
||||
expect(celsiusToFahrenheit).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
test('0 Celsius is 32 Fahrenheit', () => {
|
||||
expect(celsiusToFahrenheit(0)).toBe(32)
|
||||
})
|
||||
|
||||
test('100 Celsius is 212 Fahrenheit', () => {
|
||||
expect(celsiusToFahrenheit(100)).toBe(212)
|
||||
})
|
||||
|
||||
test('-50 Celsius is -58 Fahrenheit', () => {
|
||||
expect(celsiusToFahrenheit(-50)).toBe(-58)
|
||||
})
|
||||
|
||||
test('1000 Celsius is 1832 Fahrenheit', () => {
|
||||
expect(celsiusToFahrenheit(1000)).toBe(1832)
|
||||
})
|
||||
|
||||
test('Not a number value is NaN', () => {
|
||||
expect(celsiusToFahrenheit("Durr")).toBe(NaN)
|
||||
})
|
||||
2
test/fahrenheitToCelsius/fahrenheitToCelsius.js
Normal file
2
test/fahrenheitToCelsius/fahrenheitToCelsius.js
Normal file
@ -0,0 +1,2 @@
|
||||
const fahrenheitToCelsius = degrees => (degrees - 32) * 5/9;
|
||||
module.exports = fahrenheitToCelsius;
|
||||
26
test/fahrenheitToCelsius/fahrenheitToCelsius.test.js
Normal file
26
test/fahrenheitToCelsius/fahrenheitToCelsius.test.js
Normal file
@ -0,0 +1,26 @@
|
||||
const expect = require('expect');
|
||||
const fahrenheitToCelsius = require('./fahrenheitToCelsius.js');
|
||||
|
||||
test('fahrenheitToCelsius is a Function', () => {
|
||||
expect(fahrenheitToCelsius).toBeInstanceOf(Function);
|
||||
});
|
||||
|
||||
test('32 Fahrenheit is 0 Celsius', () => {
|
||||
expect(fahrenheitToCelsius(32)).toBe(0)
|
||||
})
|
||||
|
||||
test('212 Fahrenheit is 100 Celsius', () => {
|
||||
expect(fahrenheitToCelsius(212)).toBe(100)
|
||||
})
|
||||
|
||||
test('150 Fahrenheit is 65.55555555555556 Celsius', () => {
|
||||
expect(fahrenheitToCelsius(150)).toBe(65.55555555555556)
|
||||
})
|
||||
|
||||
test('1000 Fahrenheit is 537.7777777777778', () => {
|
||||
expect(fahrenheitToCelsius(1000)).toBe(537.7777777777778)
|
||||
})
|
||||
|
||||
test('Not a number value is NaN', () => {
|
||||
expect(fahrenheitToCelsius("Durr")).toBe(NaN)
|
||||
})
|
||||
Reference in New Issue
Block a user