-
Notifications
You must be signed in to change notification settings - Fork 323
/
Copy pathcontract-card-status-timer.spec.tsx
35 lines (28 loc) · 1.52 KB
/
contract-card-status-timer.spec.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import React from 'react';
import { render, screen } from '@testing-library/react';
import { getCardLabels, toMoment } from '@deriv/shared';
import { ContractCardStatusTimer } from '../contract-card-status-timer';
const mockedNow = Math.floor(Date.now() / 1000);
describe('ContractCardStatusTimer', () => {
const mockProps = { date_expiry: mockedNow + 1000 };
it('should render Closed status if date_expiry is not passed', () => {
render(<ContractCardStatusTimer />);
expect(screen.getByText(getCardLabels().CLOSED)).toBeInTheDocument();
});
it('should not render the component if date_expiry is passed without serverTime and no other props are passed', () => {
const { container } = render(<ContractCardStatusTimer {...mockProps} />);
expect(container).toBeEmptyDOMElement();
});
it('should render remaining time if date_expiry and serverTime are passed', () => {
render(<ContractCardStatusTimer {...mockProps} serverTime={toMoment(mockedNow)} />);
expect(screen.getByText('00:16:40')).toBeInTheDocument();
});
it('should render ticks progress if currentTick and tick_count are passed', () => {
render(<ContractCardStatusTimer {...mockProps} currentTick={2} />);
expect(screen.getByText('2 ticks')).toBeInTheDocument();
});
it('should render Closed status if isSold === true', () => {
render(<ContractCardStatusTimer {...mockProps} isSold />);
expect(screen.getByText(getCardLabels().CLOSED)).toBeInTheDocument();
});
});