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 renderedComponent = render(<Counter></Counter>); | |
renderedComponent.querySelector('.count-button').click(); | |
renderedComponent.querySelector('.count-button').click(); | |
const renderedCount = renderedComponent | |
.querySelector('.current-count') | |
.innerHTML; | |
expect(renderedCount).toEqual('2'); |
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 instance = render(<Counter></Counter>).getInstance(); | |
instance.increment(); | |
instance.increment(); | |
expect(instance.getState()).toEqual({ count: 2 }); |
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 interestToPayFor = (loanAmount) => { | |
const greaterThan2000 = { endOfRange: Money('$2000.00'), interestPerDollar: Money('$0.09'), previousInterestPerDollar: Money('$0.00') }; | |
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') }; | |
// You can move this into a configuration file so that changes | |
// in the behavior doesn't require code changes | |
const ranges = [greaterThan2000, greaterThan5000, greaterThan10000]; | |
let interestAmount = Money('$0.00'); | |
for (range of ranges) { | |
if (loanAmount.greaterThan(range.endOfRange)) { |
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
let interestAmount = Money('$0.00'); | |
- if (loanAmount.greaterThan(ranges[0].endOfRange)) { | |
- interestAmount = interestAmount.plus(calculateInterest(loanAmount, ranges[0])); | |
- } | |
- | |
- if (loanAmount.greaterThan(ranges[1].endOfRange)) { | |
- interestAmount = interestAmount.plus(calculateInterest(loanAmount, ranges[1])); | |
- } | |
- |
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 interestToPayFor = (loanAmount) => { | |
const greaterThan2000 = { endOfRange: Money('$2000.00'), interestPerDollar: Money('$0.09'), previousInterestPerDollar: Money('$0.00') }; | |
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') }; | |
let interestAmount = Money('$0.00'); | |
if (loanAmount.greaterThan(Money('$2000.00'))) { | |
interestAmount = interestAmount.plus(calculateInterest(loanAmount, greaterThan2000)); | |
} | |
if (loanAmount.greaterThan(Money('$5000.00'))) { | |
interestAmount = interestAmount.plus(calculateInterest(loanAmount, greaterThan5000)); |
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
interestAmount = interestAmount.plus(calculateInterest(loanAmount, greaterThan2000)); | |
} | |
- if (loanAmount.greaterThan(Money('$5000.00')) && loanAmount.lessThan(Money('$10001.00'))) { | |
+ if (loanAmount.greaterThan(Money('$5000.00'))) { | |
interestAmount = interestAmount.plus(calculateInterest(loanAmount, greaterThan5000)); | |
} | |
if (loanAmount.greaterThan(Money('$10000.00'))) { | |
- interestAmount = interestAmount.plus(calculateInterest(loanAmount, greaterThan5000)); |
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
let interestAmount = Money('$0.00'); | |
- if (loanAmount.greaterThan(Money('$2000.00')) && loanAmount.lessThan(Money('$5001.00'))) { | |
+ if (loanAmount.greaterThan(Money('$2000.00'))) { | |
interestAmount = interestAmount.plus(calculateInterest(loanAmount, greaterThan2000)); | |
} | |
if (loanAmount.greaterThan(Money('$5000.00')) && loanAmount.lessThan(Money('$10001.00'))) { | |
- interestAmount = interestAmount.plus(calculateInterest(loanAmount, greaterThan2000)); | |
interestAmount = interestAmount.plus(calculateInterest(loanAmount, greaterThan5000)); |
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
let interestAmount = Money('$0.00'); | |
if (loanAmount.greaterThan(Money('$2000.00')) && loanAmount.lessThan(Money('$5001.00'))) { | |
interestAmount = interestAmount.plus(calculateInterest(loanAmount, greaterThan2000)); | |
} | |
if (loanAmount.greaterThan(Money('$5000.00')) && loanAmount.lessThan(Money('$10001.00'))) { | |
interestAmount = interestAmount.plus(calculateInterest(loanAmount, greaterThan2000)); | |
interestAmount = interestAmount.plus(calculateInterest(loanAmount, greaterThan5000)); | |
} |
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)); | |
- |
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 interestToPayFor = (loanAmount) => { | |
const greaterThan2000 = { endOfRange: Money('$2000.00'), interestPerDollar: Money('$0.09'), previousInterestPerDollar: Money('$0.00') }; | |
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'); | |
interestAmount = interestAmount.plus(calculateInterest(loanAmount, greaterThan2000)); | |
return interestAmount; | |
} | |
if (loanAmount.greaterThan(Money('$5000.00')) && loanAmount.lessThan(Money('$10001.00'))) { |