Skip to content

Commit

Permalink
Add tests for initializeObject() util
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmykolyn committed Mar 11, 2022
1 parent 693a994 commit e913039
Showing 1 changed file with 65 additions and 1 deletion.
66 changes: 65 additions & 1 deletion src/utils.spec.js
Original file line number Diff line number Diff line change
@@ -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 () => {
Expand Down Expand Up @@ -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);
});
});

0 comments on commit e913039

Please sign in to comment.