From 8e4b7fa6ef0ee97d6873fcacfa85b27a9886d343 Mon Sep 17 00:00:00 2001 From: Jesse Mykolyn Date: Fri, 11 Mar 2022 18:30:37 -0500 Subject: [PATCH] Add tests for initializeObject() util --- src/utils.spec.js | 66 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/src/utils.spec.js b/src/utils.spec.js index f834421..1526b7c 100644 --- a/src/utils.spec.js +++ b/src/utils.spec.js @@ -1,4 +1,4 @@ -import { sleep, dateToString, makeDaysArray } from './utils'; +import { sleep, dateToString, makeDaysArray, initializeObject } from './utils'; describe('sleep()', () => { it('should return a Promise that resolves after the number of milliseconds provided', async () => { @@ -50,3 +50,67 @@ describe('makeDaysArray()', () => { ]); }); }); + +describe('initializeObject()', () => { + it('should enhance the data provided and return the result', () => { + const days = ['07-03-2022', '07-04-2022']; + const network = 'foo'; + const address = 'bar'; + const currency = 'baz'; + const startBalance = 0; + const ticker = 'quux'; + const expected = { + 'address': 'bar', + 'annualizedReturn': 0, + 'currency': 'baz', + 'currentValueRewardsFiat': 0, + 'data': { + 'list': [ + { + 'amountHumanReadable': 0, + 'amountPlanks': 0, + 'blockNumber': '', + 'day': '07-03-2022', + 'extrinsicHash': '', + 'numberPayouts': 0, + 'price': 0, + 'valueFiat': 0, + 'volume': 0, + }, + { + 'amountHumanReadable': 0, + 'amountPlanks': 0, + 'blockNumber': '', + 'day': '07-04-2022', + 'extrinsicHash': '', + 'numberPayouts': 0, + 'price': 0, + 'valueFiat': 0, + 'volume': 0, + }, + ], + 'numberOfDays': 2, + 'numberRewardsParsed': 0, + }, + 'firstReward': '', + 'lastReward': '', + 'message': 'empty', + 'network': 'foo', + 'startBalance': 0, + 'ticker': 'quux', + 'totalAmountHumanReadable': 0, + 'totalValueFiat': 0, + }; + + const result = initializeObject( + days, + network, + address, + currency, + startBalance, + ticker, + ); + + expect(result).toEqual(expected); + }); +});