diff --git a/__tests__/components/__snapshots__/transaction-item.test.js.snap b/__tests__/components/__snapshots__/transaction-item.test.js.snap index a8c8109..a39e0ba 100644 --- a/__tests__/components/__snapshots__/transaction-item.test.js.snap +++ b/__tests__/components/__snapshots__/transaction-item.test.js.snap @@ -29,7 +29,7 @@ exports[` should render a transaction item correctly 1`] = `

- 14:31 PM + 17:01 PM

diff --git a/__tests__/components/__snapshots__/transactions-daily.test.js.snap b/__tests__/components/__snapshots__/transactions-daily.test.js.snap index 1922919..76be04e 100644 --- a/__tests__/components/__snapshots__/transactions-daily.test.js.snap +++ b/__tests__/components/__snapshots__/transactions-daily.test.js.snap @@ -41,7 +41,7 @@ exports[` render() should render user daily transac

- 14:31 PM + 17:01 PM

@@ -94,7 +94,7 @@ exports[` render() should render user daily transac

- 14:31 PM + 17:01 PM

diff --git a/__tests__/components/transaction-item.test.js b/__tests__/components/transaction-item.test.js index 4f23fe4..295cefb 100644 --- a/__tests__/components/transaction-item.test.js +++ b/__tests__/components/transaction-item.test.js @@ -3,12 +3,33 @@ import React from 'react'; import { render, cleanup } from 'react-testing-library'; import { ThemeProvider } from 'styled-components'; +import dateFns from 'date-fns'; import 'jest-dom/extend-expect'; import { TransactionItemComponent } from '../../app/components/transaction-item'; import { appTheme } from '../../app/theme'; -afterEach(cleanup); +let originalDate; +const fixedDate = new Date('2018-02-28T09:39:59'); + +beforeAll(() => { + // $FlowFixMe + dateFns.format = jest.fn(() => '17:01 PM'); + + originalDate = global.Date; + global.Date = class extends Date { + constructor() { + super(); + + return fixedDate; + } + }; +}); +afterAll(() => { + global.Date = originalDate; + dateFns.format.mockRestore(); + cleanup(); +}); describe('', () => { test('should render a transaction item correctly', () => { @@ -19,7 +40,7 @@ describe('', () => { address='123456789123456789123456789123456789' transactionId='a0s9dujo23j0' amount={0.8652} - date='2019-02-20T19:31:57.117Z' + date={new Date().toString()} zecPrice={2.94} fees={0.0001} /> diff --git a/__tests__/components/transactions-daily.test.js b/__tests__/components/transactions-daily.test.js index 3a5fc8d..6efd831 100644 --- a/__tests__/components/transactions-daily.test.js +++ b/__tests__/components/transactions-daily.test.js @@ -3,12 +3,33 @@ import React from 'react'; import { render, cleanup } from 'react-testing-library'; import { ThemeProvider } from 'styled-components'; +import dateFns from 'date-fns'; import 'jest-dom/extend-expect'; import { TransactionDailyComponent } from '../../app/components/transaction-daily'; import { appTheme } from '../../app/theme'; -afterEach(cleanup); +let originalDate; +const fixedDate = new Date('2018-02-28T09:39:59'); + +beforeAll(() => { + // $FlowFixMe + dateFns.format = jest.fn(() => '17:01 PM'); + + originalDate = global.Date; + global.Date = class extends Date { + constructor() { + super(); + + return fixedDate; + } + }; +}); +afterAll(() => { + global.Date = originalDate; + dateFns.format.mockRestore(); + cleanup(); +}); describe('', () => { describe('render()', () => { diff --git a/config/daemon/parse-zcash-conf.js b/config/daemon/parse-zcash-conf.js index 0e07470..2625c20 100644 --- a/config/daemon/parse-zcash-conf.js +++ b/config/daemon/parse-zcash-conf.js @@ -34,7 +34,6 @@ type ZcashConfFile = { export const parseZcashConf = (): Promise> => new Promise((resolve, reject) => { fs.readFile(locateZcashConf(), (err, file) => { - // TODO: Maybe we can create the zcash.conf on the fly here if (err) return reject(err); const fileString = file.toString(); @@ -42,15 +41,19 @@ export const parseZcashConf = (): Promise> => new Promise((resolve // $FlowFixMe const { rpcuser, rpcpassword, ...payload }: ZcashConfFile = filterObjectNullKeys( fileString.split('\n').reduce((acc, cur) => { + if (!cur) return acc; + + const line = cur.trim(); + + if (line.startsWith('#')) return acc; + const [key, value] = cur.split('='); - return { ...acc, [key]: value }; + return { ...acc, [key.trim().toLowerCase()]: value.trim() }; }, {}), ); - if (rpcuser && rpcpassword) { - store.set('rpcuser', rpcuser); - store.set('rpcpassword', rpcpassword); - } + store.set('rpcuser', rpcuser || ''); + store.set('rpcpassword', rpcpassword || ''); // $FlowFixMe resolve(Object.keys(payload).reduce((acc, key) => acc.concat(`-${key}=${payload[key]}`), [])); diff --git a/package.json b/package.json index a310468..b0ca03d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "zec-react-wallet", - "version": "0.4.3", + "version": "0.4.4", "description": "Zcash Reference Wallet", "main": "config/main.js", "license": "MIT",