UNPKG

react-native-easy-calendar

Version:

Customizable, easy-to-use, performant calendar components for React Native

67 lines (60 loc) 2.13 kB
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } import React from 'react'; import { render } from '@testing-library/react-native'; import { ThemeContext, LocaleContext } from '../Contexts'; import { DefaultTheme } from '../Themes'; import { DefaultLocale } from '../Locales'; import Weekdays from './Weekdays'; test('Weekdays render without error', () => { const weekdays = new WeekdaysPage(); expect(weekdays.component).toBeTruthy(); }); test('Weekday receives locale context', () => { const weekdays = new WeekdaysPage(); expect(weekdays.array).toStrictEqual(locale.weekdays); }); describe('Theme context', () => { test('Weekday container applies weekdayContainer theme', () => { const weekdays = new WeekdaysPage(); expect(weekdays.component).toHaveStyle(theme.weekdaysContainer); }); test('Weekday text applies weekdayText theme', () => { const weekdays = new WeekdaysPage(); expect(weekdays.text).toHaveStyle(theme.weekdayText); }); }); class WeekdaysPage { constructor() { _defineProperty(this, "component", void 0); _defineProperty(this, "text", void 0); _defineProperty(this, "array", void 0); const { getByTestId, getAllByTestId } = render( /*#__PURE__*/React.createElement(LocaleContext.Provider, { value: locale }, /*#__PURE__*/React.createElement(ThemeContext.Provider, { value: theme }, /*#__PURE__*/React.createElement(Weekdays, { days: locale.weekdays })))); const allWeekdays = getAllByTestId('weekday'); this.component = getByTestId('weekdays'); this.array = allWeekdays.map(day => day.children[0]); this.text = allWeekdays[0]; } } const locale = { ...DefaultLocale, weekdays: ['A', 'B', 'C', 'D', 'E', 'F', 'G'] }; const theme = { ...DefaultTheme, weekdaysContainer: { marginTop: 10, backgroundColor: 'black' }, weekdayText: { marginBottom: 10, color: 'green' } }; //# sourceMappingURL=Weekdays.test.js.map