Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/components/ui/calendar/calendar.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ jest.useFakeTimers();
const now: Date = new Date();
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0);

const CURRENT_MONTH: number = now.getMonth();

interface State {
date: Date;
}
Expand Down Expand Up @@ -63,8 +61,8 @@ class TestApplication extends React.Component<TestAppProps, State> {
describe('@calendar: component checks', () => {

it('* date changes', () => {
const expectedDate: Date = new Date(2019, CURRENT_MONTH, 5);
const application: RenderAPI = render(<TestApplication/>);
const expectedDate: Date = new Date(now.getFullYear(), now.getMonth(), 5);
const application: RenderAPI = render(<TestApplication date={expectedDate}/>);

fireEvent.press(application.getAllByText('5')[0]);
const { date } = application.getByType(Calendar).props;
Expand Down
15 changes: 8 additions & 7 deletions src/components/ui/calendar/rangeCalendar.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import {
render,
fireEvent,
render,
RenderAPI,
} from 'react-native-testing-library';
import { ApplicationProvider } from '@kitten/theme';
Expand All @@ -17,7 +17,8 @@ import { CalendarRange } from '@kitten/ui/calendar/type';

jest.useFakeTimers();

const CURRENT_MONTH: number = new Date().getMonth();
const now: Date = new Date();
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0);

interface State {
range: CalendarRange<Date>;
Expand Down Expand Up @@ -56,7 +57,7 @@ class TestApplication extends React.Component<TestAppProps, State> {
describe('@range-calendar: component checks', () => {

it('* start range date selected properly', () => {
const expectedStartDate: Date = new Date(2019, CURRENT_MONTH, 11);
const expectedStartDate: Date = new Date(now.getFullYear(), now.getMonth(), 11);
const application: RenderAPI = render(<TestApplication/>);

fireEvent.press(application.getAllByText('11')[0]);
Expand All @@ -66,8 +67,8 @@ describe('@range-calendar: component checks', () => {
});

it('* range selected works properly', () => {
const expectedStartDate: Date = new Date(2019, CURRENT_MONTH, 11);
const expectedEndDate: Date = new Date(2019, CURRENT_MONTH, 26);
const expectedStartDate: Date = new Date(now.getFullYear(), now.getMonth(), 11);
const expectedEndDate: Date = new Date(now.getFullYear(), now.getMonth(), 26);
const application: RenderAPI = render(<TestApplication/>);

fireEvent.press(application.getAllByText('11')[0]);
Expand All @@ -79,7 +80,7 @@ describe('@range-calendar: component checks', () => {
});

it('* range re-selected properly 1', () => {
const expectedStartDate: Date = new Date(2019, CURRENT_MONTH, 19);
const expectedStartDate: Date = new Date(now.getFullYear(), now.getMonth(), 19);
const application: RenderAPI = render(<TestApplication/>);

fireEvent.press(application.getAllByText('11')[0]);
Expand All @@ -92,7 +93,7 @@ describe('@range-calendar: component checks', () => {
});

it('* range re-selected properly 2', () => {
const expectedStartDate: Date = new Date(2019, CURRENT_MONTH, 8);
const expectedStartDate: Date = new Date(now.getFullYear(), now.getMonth(), 8);
const application: RenderAPI = render(<TestApplication/>);

fireEvent.press(application.getAllByText('11')[0]);
Expand Down