Skip to content

Commit

Permalink
add rounding to fluid ounces
Browse files Browse the repository at this point in the history
  • Loading branch information
frogermcs committed Dec 18, 2017
1 parent b8f9138 commit 621a1e5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"firebase-admin": "~5.4.0",
"firebase-functions": "^0.7.0",
"geo-tz": "^3.3.3",
"mathjs": "^3.18.0",
"moment-timezone": "^0.5.14"
},
"devDependencies": {
Expand Down
4 changes: 3 additions & 1 deletion functions/test/water-log-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const sinon = require('sinon');
const chai = require('chai');

const math = require('mathjs');

const Constants = require('../constants.js');
const WaterLog = require('../water-log.js');
const TimeManager = require('../time-manager.js');
Expand Down Expand Up @@ -82,7 +84,7 @@ describe('WaterLog', () => {
});

it('Should save logged fl oz of water', (done) => {
const expectedMililiters = Constants.OZ_TO_ML;
const expectedMililiters = math.round(Constants.OZ_TO_ML);
const loggedWaterInput = {unit: "fl oz", amount: 1};
const expectedLoggedWater = {
userId: exampleUser.userId,
Expand Down
3 changes: 2 additions & 1 deletion functions/water-log.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const Constants = require('./constants.js');
const math = require('mathjs');

class WaterLog {
constructor(firebaseAdmin, timeManager) {
Expand All @@ -13,7 +14,7 @@ class WaterLog {
} else if (loggedWater.unit === "ml") {
mililiters = loggedWater.amount;
} else if (loggedWater.unit === "fl oz") {
mililiters = loggedWater.amount * Constants.OZ_TO_ML;
mililiters = math.round(loggedWater.amount * Constants.OZ_TO_ML);
}

const waterLogData = {
Expand Down

0 comments on commit 621a1e5

Please sign in to comment.