test(unit): mock date in transaction-item test

This commit is contained in:
georgelima 2019-03-05 17:01:59 -03:00
parent c3f5e5293b
commit 9297166baf
2 changed files with 17 additions and 3 deletions

View File

@ -29,7 +29,7 @@ exports[`<TransactionItem /> should render a transaction item correctly 1`] = `
<p <p
class="sc-kgoBCf goviHQ sc-htpNat pRhzD" class="sc-kgoBCf goviHQ sc-htpNat pRhzD"
> >
23:20 PM 17:01 PM
</p> </p>
</div> </div>
</div> </div>

View File

@ -8,7 +8,21 @@ import 'jest-dom/extend-expect';
import { TransactionItemComponent } from '../../app/components/transaction-item'; import { TransactionItemComponent } from '../../app/components/transaction-item';
import { appTheme } from '../../app/theme'; import { appTheme } from '../../app/theme';
afterEach(cleanup); let originalDate;
beforeEach(() => {
originalDate = global.Date;
global.Date = class extends Date {
constructor() {
super();
return '2019-03-05T19:58:35.457Z';
}
};
});
afterEach(() => {
global.Date = originalDate;
cleanup();
});
describe('<TransactionItem />', () => { describe('<TransactionItem />', () => {
test('should render a transaction item correctly', () => { test('should render a transaction item correctly', () => {
@ -19,7 +33,7 @@ describe('<TransactionItem />', () => {
address='123456789123456789123456789123456789' address='123456789123456789123456789123456789'
transactionId='a0s9dujo23j0' transactionId='a0s9dujo23j0'
amount={0.8652} amount={0.8652}
date={new Date(Date.UTC(2018, 10, 20, 1, 20, 35)).toString()} date={new Date().toString()}
zecPrice={2.94} zecPrice={2.94}
fees={0.0001} fees={0.0001}
/> />