This repository has been archived by the owner on Dec 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 975
Unit tests for Ledger export utilities #4429
Closed
Closed
Conversation
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
- add example Ledger transaction data `test/unit/lib/exampleLedgerData.js` - add tests for `ledgerExportUtil.js#transactionsToCSVDataURL` (re: #4346 (comment)) - add tests for `ledgerExportUtil.js#getTransactionCSVText` - fix how `ledgerExportUtil.js#transactionsToCSVDataURL` handled empty input - add sanity check tests on example transaction data - use es6 object property notation in `ledgerExportUtil.js` (re: #4346 (comment))
…rtUtil.js Wrote failing placeholder tests (`describe` and `it` blocks) for remaining ledgerExportUtil methods w/out tests: getTransactionCSVRows getPublisherVoteData getTransactionsByViewingIds getTotalContribution these tests fail with message "not yet impl"
added tests for #getTransactionCSVRows: ``` getTransactionCSVRows ✓ for empty input, returns an array containing only the expected CSV header row ✓ returns a CSV row array, where the first row is the expected header row up to the currency column (which varies) ✓ returns a CSV row array with the same number of columns in every row ✓ returns a CSV row array with expected data types for each column in every row ✓ returns the same output for a single transaction input as an array of 1 element and a plain transaction object ✓ given a transaction, returns an array containing the right number of CSV rows: 1 header row, 1 row per publisher, and if addTotalRow===true, 1 row with totals ✓ when argument addTotalRow===true, there should be a total row with correct totals for each numeric column Sum for column Votes (#1) across 10 rows (=43) matches expected value (43) Sum for column Fraction (#2) across 10 rows (=1) matches expected value (1) Sum for column BTC (#3) across 10 rows (=0.0000813917) matches expected value (0.0000813917) ``` also split out shared helper methods for getTransactionCSVText/getTransactionCSVRows Auditors: @diracdeltas
Impl tests for ledgerExportUtil3getPublisherVoteData: ``` getPublisherVoteData ✓ should return a publisher data object with 1 key per publisher ✓ the sum of the "fraction" value across all publisher entries should be 1 ✓ the sum of the "votes" value across all publisher entries should be equal to the overall "votes" y for the transaction object given as input each publisher value ✓ should have "votes" (type number) defined ✓ should have "fraction" (type number) defined ✓ should have "contribution" (type object) defined each publisher->contribution entry ✓ should have "satoshis" (type number) defined ✓ should have "fiat" (type number) defined ✓ should have "currency" (type string) defined ``` Auditors: @diracdeltas
Impl tests for getTransactionsByViewingIds: ``` getTransactionsByViewingIds ✓ given a single viewingId as a string, it returns an array containing just that transaction (if it exists) ✓ given viewingIds as an array, it filters a transactions array for those transactions ``` Auditors: @diracdeltas
Impl tests for getTotalContribution: ``` getTotalContribution ✓ returns a total contribution object total contribution object ✓ has a key "satoshis" with value of type number (>= 0) ✓ has a key "fiat" associated with an object containing two subkeys, "amount" (number) and "currency" (string) ✓ has a key, fee with value of type number (>= 0) ``` Auditors: @diracdeltas
diracdeltas
reviewed
Oct 2, 2016
|
||
assert.equal(sum, expectedTotal, `Sum for column ${colIdx} across ${rows.length} rows does not match expected value`) | ||
let columnNames = CSV_HEADER_ROW_PREFIX_COLUMNS.concat(['Fiat']) | ||
console.log(`\tSum for column ${columnNames[colIdx]} (#${colIdx}) across ${rows.length} rows (=${sum}) matches expected total (${expectedTotal})`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove this logging
lgtm after rebase, thanks for the tests! |
2 tasks
Sweet, thanks. |
diracdeltas
added a commit
that referenced
this pull request
Oct 2, 2016
…-again Add tests for Ledger export utilities (and fix bugs) (rebased #4429)
This was referenced Oct 4, 2016
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Follow-up to #4332 and #4346 (comment)
git rebase -i
to squash commits (if needed).Test Plan:
ledgerExportUtilTest.js
with:ledgerExportUtilTest
tests running (and passing)cc/ @diracdeltas