File tree Expand file tree Collapse file tree 2 files changed +21
-12
lines changed Expand file tree Collapse file tree 2 files changed +21
-12
lines changed Original file line number Diff line number Diff line change 1
1
const calculateTip = ( total , tipPercent = .25 ) => total + ( total * tipPercent )
2
2
3
+ const fahrenheitToCelsius = ( temp ) => {
4
+ return ( temp - 32 ) / 1.8
5
+ }
6
+
7
+ const celsiusToFahrenheit = ( temp ) => {
8
+ return ( temp * 1.8 ) + 32
9
+ }
10
+
3
11
module . exports = {
4
- calculateTip
12
+ calculateTip,
13
+ fahrenheitToCelsius,
14
+ celsiusToFahrenheit
5
15
}
Original file line number Diff line number Diff line change 1
- const { calculateTip } = require ( '../src/math' )
1
+ const { calculateTip, celsiusToFahrenheit , fahrenheitToCelsius } = require ( '../src/math' )
2
2
3
3
test ( 'Should calculate total with tip' , ( ) => {
4
4
const total = calculateTip ( 10 , .3 )
@@ -10,13 +10,12 @@ test('Should calculate total with default tip', () => {
10
10
expect ( total ) . toBe ( 12.5 )
11
11
} )
12
12
13
- //
14
- // Why test?
15
- //
16
- // - Saves time
17
- // - Creates reliable software
18
- // - Gives flexibility to developers
19
- // - Refactoring
20
- // - Collaborating
21
- // - Profiling
22
- // - Peace of mind
13
+ test ( 'Should convert 32 F to 0 C' , ( ) => {
14
+ const temp = fahrenheitToCelsius ( 32 )
15
+ expect ( temp ) . toBe ( 0 )
16
+ } )
17
+
18
+ test ( 'Should convert 0 C to 32 F' , ( ) => {
19
+ const temp = celsiusToFahrenheit ( 0 )
20
+ expect ( temp ) . toBe ( 32 )
21
+ } )
You can’t perform that action at this time.
0 commit comments