test(snapshot): mock date in TransactionDaily and update snapshot

This commit is contained in:
georgelima 2019-03-05 17:26:28 -03:00
parent 3df53c98ae
commit ae303300d2
2 changed files with 23 additions and 3 deletions

View File

@ -41,7 +41,7 @@ exports[`<TransactionDailyComponent /> render() should render user daily transac
<p
class="sc-kgoBCf goviHQ sc-htpNat pRhzD"
>
16:31 PM
17:01 PM
</p>
</div>
</div>
@ -94,7 +94,7 @@ exports[`<TransactionDailyComponent /> render() should render user daily transac
<p
class="sc-kgoBCf goviHQ sc-htpNat pRhzD"
>
16:31 PM
17:01 PM
</p>
</div>
</div>

View File

@ -3,12 +3,32 @@
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(() => {
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('<TransactionDailyComponent />', () => {
describe('render()', () => {