Will Baxter#55
Open
MrStashy wants to merge 15 commits into
Open
Conversation
…ance after transaction property
… to overdraft limit
…ecking accounts after opening
vherus
reviewed
Jun 18, 2024
Comment on lines
+65
to
+67
| expect( | ||
| testAccount.getTransactions("2023-9-4", "2023-9-10").length | ||
| ).toEqual(3); |
Contributor
There was a problem hiding this comment.
I like this, but I think you should also have some expects for each of the transaction dates to ensure the correct transactions are being returned
vherus
reviewed
Jun 18, 2024
Comment on lines
+17
to
+27
| credit(amount, testDate) { | ||
| if (this.constructor.name === "SavingsAccount") { | ||
| const today = new Date(); | ||
| const oneYearAgo = today - 365 * 24 * 60 * 60 * 1000; | ||
| const totalCreditsThisYear = this.getTransactions(oneYearAgo, today) | ||
| .filter((transaction) => transaction.constructor.name === "Credit") | ||
| .reduce((a, b) => a + Number(b.amount), 0); | ||
| if (totalCreditsThisYear + amount > 20000) { | ||
| throw new Error("You are only able to deposit £20,000 per year"); | ||
| } | ||
| } |
vherus
reviewed
Jun 18, 2024
Comment on lines
+47
to
+54
| getDate(testDate) { | ||
| if (testDate) { | ||
| const date = new Date(testDate); | ||
| return date; | ||
| } | ||
| const date = new Date(); | ||
| return date; | ||
| } |
Contributor
There was a problem hiding this comment.
if (testDate) { // why is it called testDate?
return new Date(testDate)
}
return new Date()
vherus
reviewed
Jun 18, 2024
Comment on lines
+133
to
+136
| const filteredTransactions = this.#transactions.filter( | ||
| (transaction) => transaction.constructor.name === "Credit" | ||
| ); | ||
| return [...filteredTransactions]; |
Contributor
There was a problem hiding this comment.
filter will return a new array containing the filtered items so you're safe to return it directly
return this.#transactions.filter(
(transaction) => transaction.constructor.name === "Credit"
)
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.