Skip to content

Commit

Permalink
pr comments fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Inbal-Tish committed Aug 11, 2021
1 parent f16adc6 commit 987a140
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/expandableCalendar/Context/Presenter.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const {default: Presenter} = require('./Presenter');
import XDate from 'xdate';
import {UPDATE_SOURCES} from '../commons';
import {UpdateSources} from '../commons';
import {toMarkingFormat} from '../../interface';


Expand All @@ -14,7 +14,7 @@ describe('Context provider tests', () => {
const today1 = XDate();
const today2 = new Date();
const todayDate = toMarkingFormat(XDate());
const updateSources = UPDATE_SOURCES.CALENDAR_INIT;
const updateSources = UpdateSources.CALENDAR_INIT;

describe('isPastDate function tests', () => {
it('Expect to get true while passing a past date', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/expandableCalendar/Context/Provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Presenter from './Presenter';


const commons = require('../commons');
const updateSources = commons.UPDATE_SOURCES;
const updateSources = commons.UpdateSources;
const TOP_POSITION = 65;

interface Props {
Expand Down
8 changes: 4 additions & 4 deletions src/expandableCalendar/WeekCalendar/presenter.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const {UPDATE_SOURCES} = require('../commons');
const {UpdateSources} = require('../commons');
const {default: Presenter} = require('./presenter');

describe('WeekCalendar presenter tests', () => {
Expand All @@ -17,7 +17,7 @@ describe('WeekCalendar presenter tests', () => {
prevDate: '2021-01-13'
};

const makeContext = (datesInWeek = twoDaysSameWeek, updateSource = UPDATE_SOURCES.WEEK_SCROLL) => {
const makeContext = (datesInWeek = twoDaysSameWeek, updateSource = UpdateSources.WEEK_SCROLL) => {
return {
...datesInWeek,
updateSource
Expand Down Expand Up @@ -59,7 +59,7 @@ describe('WeekCalendar presenter tests', () => {
});

it('Expect component to update when dates are not in the same week', () => {
const context = makeContext(twoDaysDifferentWeek, UPDATE_SOURCES.PAGE_SCROLL);
const context = makeContext(twoDaysDifferentWeek, UpdateSources.PAGE_SCROLL);
const prevContext = makeContext(twoSomeDays);
const {shouldComponentUpdate} = makeUUT();
const shouldUpdate = shouldComponentUpdate(context, prevContext);
Expand Down Expand Up @@ -145,7 +145,7 @@ describe('WeekCalendar presenter tests', () => {
const {onDayPress} = makeUUT({context});

onDayPress(context, {dateString: '2021-01-22'});
expect(setDate).toBeCalledWith('2021-01-22', UPDATE_SOURCES.DAY_PRESS);
expect(setDate).toBeCalledWith('2021-01-22', UpdateSources.DAY_PRESS);
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/expandableCalendar/WeekCalendar/presenter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {WeekCalendarProps} from './index';


const commons = require('../commons');
const updateSources = commons.UPDATE_SOURCES;
const updateSources = commons.UpdateSources;
// must be a positive number
const NUMBER_OF_PAGES = 2;

Expand Down
2 changes: 1 addition & 1 deletion src/expandableCalendar/agendaList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import asCalendarConsumer from './asCalendarConsumer';


const commons = require('./commons');
const updateSources = commons.UPDATE_SOURCES;
const updateSources = commons.UpdateSources;

interface Props extends SectionListProps<any, DefaultSectionT> {
/** day format in section title. Formatting values: http://arshaw.com/xdate/#Formatting */
Expand Down
7 changes: 3 additions & 4 deletions src/expandableCalendar/commons.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Platform, Dimensions, I18nManager} from 'react-native';
import {Platform, Dimensions, I18nManager, PlatformIOSStatic} from 'react-native';

const {height, width} = Dimensions.get('window');

Expand All @@ -8,11 +8,10 @@ export const isIos = Platform.OS === 'ios';
export const screenWidth = width;
export const screenHeight = height;
export const screenAspectRatio = screenWidth < screenHeight ? screenHeight / screenWidth : screenWidth / screenHeight;
// @ts-expect-error
export const isTablet = Platform.isPad || (screenAspectRatio < 1.6 && Math.max(screenWidth, screenHeight) >= 900);
export const isTablet = (Platform as PlatformIOSStatic).isPad || (screenAspectRatio < 1.6 && Math.max(screenWidth, screenHeight) >= 900);
export const todayString = 'today';

export enum UPDATE_SOURCES {
export enum UpdateSources {
CALENDAR_INIT = 'calendarInit',
TODAY_PRESS = 'todayPress',
LIST_DRAG = 'listDrag',
Expand Down
2 changes: 1 addition & 1 deletion src/expandableCalendar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import Week from './week';


const commons = require('./commons');
const updateSources = commons.UPDATE_SOURCES;
const updateSources = commons.UpdateSources;
enum Positions {
CLOSED = 'closed',
OPEN = 'open'
Expand Down
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {ColorValue, ViewStyle, TextStyle} from 'react-native';
import {UPDATE_SOURCES} from './expandableCalendar/commons';
import {UpdateSources} from './expandableCalendar/commons';


export type Direction = 'left' | 'right';
export type UpdateSource = keyof typeof UPDATE_SOURCES;
export type UpdateSource = keyof typeof UpdateSources;
export type DateData = {
year: number,
month: number,
Expand Down

0 comments on commit 987a140

Please sign in to comment.