Skip to content

Commit

Permalink
feat(*): private property
Browse files Browse the repository at this point in the history
  • Loading branch information
hqmaker committed Mar 4, 2020
1 parent 599c01e commit 244cf91
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/calendar-input/calendar-input.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('calendar-input', () => {

it('should focus input on after `focus` call', () => {
const calendarInput = mount<CalendarInput>(<CalendarInput />);
const focusTarget = calendarInput.instance().customCalendarTarget;
const focusTarget = calendarInput.instance().getCustomCalendarTarget();

jest.spyOn(focusTarget, 'focus');

Expand All @@ -89,7 +89,7 @@ describe('calendar-input', () => {

it('should blur input on after `blur` call', () => {
const calendarInput = mount<CalendarInput>(<CalendarInput />);
const focusTarget = calendarInput.instance().customCalendarTarget;
const focusTarget = calendarInput.instance().getCustomCalendarTarget();

jest.spyOn(focusTarget, 'blur');

Expand Down Expand Up @@ -282,7 +282,7 @@ describe('calendar-input', () => {

it('should focus on input after escape key was pressed in calendar', () => {
const wrapper = mount<CalendarInput>(<CalendarInput />);
const calendarTarget = wrapper.instance().customCalendarTarget;
const calendarTarget = wrapper.instance().getCustomCalendarTarget();
const calendarNode = wrapper.find('.calendar');

jest.spyOn(calendarTarget, 'focus');
Expand All @@ -294,7 +294,7 @@ describe('calendar-input', () => {

it('should focus on input after calendar icon was clicked', () => {
const wrapper = mount<CalendarInput>(<CalendarInput />);
const calendarTarget = wrapper.instance().customCalendarTarget;
const calendarTarget = wrapper.instance().getCustomCalendarTarget();

jest.spyOn(calendarTarget, 'focus');
const iconNode = wrapper.find('.icon');
Expand Down
7 changes: 5 additions & 2 deletions src/calendar-input/calendar-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,7 @@ export class CalendarInput extends React.Component<CalendarInputProps> {
/**
* @type {Input}
*/
// TODO [issues/1018] переписать тесты нужно, что бы private был
customCalendarTarget;
private customCalendarTarget;

private nativeCalendarTarget;

Expand Down Expand Up @@ -753,6 +752,10 @@ export class CalendarInput extends React.Component<CalendarInputProps> {
this.timeoutId = null;
}, 0);
}

public getCustomCalendarTarget() {
return this.customCalendarTarget;
}
}

class ThemedCalendarInput extends CalendarInput {}
Expand Down
2 changes: 1 addition & 1 deletion src/checkbox-group/checkbox-group.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('checkbox-group', () => {
<CheckBox />
</CheckBoxGroup>
);
const firstCheckboxInstance = checkboxGroup.instance().checkboxes[0];
const firstCheckboxInstance = checkboxGroup.instance().getCheckboxes()[0];

jest.spyOn(firstCheckboxInstance, 'focus');
checkboxGroup.instance().focus();
Expand Down
7 changes: 5 additions & 2 deletions src/checkbox-group/checkbox-group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,7 @@ export class CheckBoxGroup extends React.PureComponent<CheckBoxGroupProps> {
value: []
};

// TODO [issues/1018] переписать тесты нужно, что бы private был
checkboxes: any[];
private checkboxes: any[];

render() {
let children = null;
Expand Down Expand Up @@ -216,6 +215,10 @@ export class CheckBoxGroup extends React.PureComponent<CheckBoxGroupProps> {
}
}

public getCheckboxes() {
return this.checkboxes;
}

/**
* Убирает фокус с группы чекбокс-кнопок.
*/
Expand Down

0 comments on commit 244cf91

Please sign in to comment.