Skip to content

Commit

Permalink
Unit tests fo inch-millimeter conversions, version 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tsmx committed Apr 3, 2022
1 parent e65209e commit d6b6b11
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tsmx/weather-tools",
"version": "1.0.1",
"version": "1.1.0",
"description": "Toolset for calculating wind chill, dew point, heat index and more.",
"main": "weather-tools.js",
"repository": {
Expand Down
33 changes: 27 additions & 6 deletions test/wt-conversions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ describe('weather-tools unit conversion test suite', () => {
const wt = require('../weather-tools');

const round2 = require('./test-helpers').roundToTwo;

const speedRefValues = {
kmhToMph: {
kmh: 15.0,
Expand All @@ -15,7 +15,7 @@ describe('weather-tools unit conversion test suite', () => {
}
}

const tempRefValues = {
const temperatureRefValues = {
celsiusToFahrenheit: {
clesius: 21.0,
fahrenheit: 69.8
Expand All @@ -26,6 +26,17 @@ describe('weather-tools unit conversion test suite', () => {
}
}

const lengthRefValues = {
inchToMillimeter: {
inch: 17,
millimeter: 431.8
},
millimeterToInch: {
millimeter: 57,
inch: 2.24409
}
}

it('tests a mph-to-kmh conversion', () => {
expect(round2(wt.mphToKmh(speedRefValues.mphToKmh.mph))).toEqual(round2(speedRefValues.mphToKmh.kmh));
});
Expand All @@ -35,13 +46,23 @@ describe('weather-tools unit conversion test suite', () => {
});

it('tests a celsius-to-fahrenheit conversion', () => {
expect(round2(wt.celsiusToFahrenheit(tempRefValues.celsiusToFahrenheit.clesius)))
.toEqual(round2(tempRefValues.celsiusToFahrenheit.fahrenheit));
expect(round2(wt.celsiusToFahrenheit(temperatureRefValues.celsiusToFahrenheit.clesius)))
.toEqual(round2(temperatureRefValues.celsiusToFahrenheit.fahrenheit));
});

it('tests a fahrenheit-to-celsius conversion', () => {
expect(round2(wt.fahrenheitToCelsius(tempRefValues.fahrenheitToCelsius.fahrenheit)))
.toEqual(round2(tempRefValues.fahrenheitToCelsius.celsius));
expect(round2(wt.fahrenheitToCelsius(temperatureRefValues.fahrenheitToCelsius.fahrenheit)))
.toEqual(round2(temperatureRefValues.fahrenheitToCelsius.celsius));
});

it('tests a inch-to-millimeter conversion', () => {
expect(round2(wt.inchToMillimeter(lengthRefValues.inchToMillimeter.inch)))
.toEqual(round2(lengthRefValues.inchToMillimeter.millimeter));
});

it('tests a millimeter-to-inch conversion', () => {
expect(round2(wt.millimeterToInch(lengthRefValues.millimeterToInch.millimeter)))
.toEqual(round2(lengthRefValues.millimeterToInch.inch));
});

});

0 comments on commit d6b6b11

Please sign in to comment.