Created
November 22, 2018 10:36
-
-
Save FagnerMartinsBrack/6b34237b25486e197d10a8dfe8aa87aa to your computer and use it in GitHub Desktop.
(Medium) - How TDD Can Prevent Over-Engineering
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const greaterThan5000 = { endOfRange: Money('$5000.00'), interestPerDollar: Money('$0.14'), previousInterestPerDollar: Money('$0.09') }; | |
const greaterThan10000 = { endOfRange: Money('$10000.00'), interestPerDollar: Money('$0.21'), previousInterestPerDollar: Money('$0.14') }; | |
- if (loanAmount.greaterThan(Money('$2000.00')) && loanAmount.lessThan(Money('$5001.00'))) { | |
- let interestAmount = Money('$0.00'); | |
+ let interestAmount = Money('$0.00'); | |
+ if (loanAmount.greaterThan(Money('$2000.00')) && loanAmount.lessThan(Money('$5001.00'))) { | |
interestAmount = interestAmount.plus(calculateInterest(loanAmount, greaterThan2000)); | |
- | |
- return interestAmount; | |
} | |
if (loanAmount.greaterThan(Money('$5000.00')) && loanAmount.lessThan(Money('$10001.00'))) { | |
- let interestAmount = Money('$0.00'); | |
- | |
interestAmount = interestAmount.plus(calculateInterest(loanAmount, greaterThan2000)); | |
interestAmount = interestAmount.plus(calculateInterest(loanAmount, greaterThan5000)); | |
- | |
- return interestAmount; | |
} | |
if (loanAmount.greaterThan(Money('$10000.00'))) { | |
- let interestAmount = Money('$0.00'); | |
- | |
interestAmount = interestAmount.plus(calculateInterest(loanAmount, greaterThan2000)); | |
interestAmount = interestAmount.plus(calculateInterest(loanAmount, greaterThan5000)); | |
interestAmount = interestAmount.plus(calculateInterest(loanAmount, greaterThan10000)); | |
- | |
- return interestAmount; | |
} | |
- return Money('$0.00'); | |
+ return interestAmount; | |
}; | |
QUnit.module('Loans of $2000 and below are interest-free. For example'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment