Skip to content

Commit 694b6de

Browse files
committed
Avoid unnecessary destructuring
1 parent e9654ab commit 694b6de

File tree

7 files changed

+57
-26
lines changed

7 files changed

+57
-26
lines changed

src/Calendar/Navigation.spec.jsx

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ describe('Navigation', () => {
2323

2424
const children = [...container.firstElementChild.children];
2525

26-
const [prev2, prev, drillUp, next, next2] = children;
26+
const prev2 = children[0];
27+
const prev = children[1];
28+
const drillUp = children[2];
29+
const next = children[3];
30+
const next2 = children[4];
2731

2832
expect(children).toHaveLength(5);
2933
expect(prev2).toHaveAttribute('type', 'button');
@@ -38,7 +42,9 @@ describe('Navigation', () => {
3842

3943
const children = [...container.firstElementChild.children];
4044

41-
const [prev, drillUp, next] = children;
45+
const prev = children[0];
46+
const drillUp = children[1];
47+
const next = children[2];
4248

4349
expect(children).toHaveLength(3);
4450
expect(prev).toHaveAttribute('type', 'button');
@@ -98,7 +104,12 @@ describe('Navigation', () => {
98104
/>,
99105
);
100106

101-
const [prev2, prev, , next, next2] = [...container.firstElementChild.children];
107+
const children = [...container.firstElementChild.children];
108+
109+
const prev2 = children[0];
110+
const prev = children[1];
111+
const next = children[3];
112+
const next2 = children[4];
102113

103114
expect(prev2).toHaveTextContent('prev2Label');
104115
expect(prev).toHaveTextContent('prevLabel');
@@ -111,7 +122,9 @@ describe('Navigation', () => {
111122
<Navigation {...defaultProps} navigationAriaLive="polite" view="month" />,
112123
);
113124

114-
const [, , navigation] = [...container.firstElementChild.children];
125+
const children = [...container.firstElementChild.children];
126+
127+
const navigation = children[2];
115128

116129
expect(navigation).toHaveAttribute('aria-live', 'polite');
117130
});
@@ -129,7 +142,13 @@ describe('Navigation', () => {
129142
/>,
130143
);
131144

132-
const [prev2, prev, navigation, next, next2] = [...container.firstElementChild.children];
145+
const children = [...container.firstElementChild.children];
146+
147+
const prev2 = children[0];
148+
const prev = children[1];
149+
const navigation = children[2];
150+
const next = children[3];
151+
const next2 = children[4];
133152

134153
expect(prev2).toHaveAccessibleName('prev2AriaLabel');
135154
expect(prev).toHaveAccessibleName('prevAriaLabel');

src/CenturyView.spec.jsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ describe('CenturyView', () => {
6262
);
6363

6464
const tiles = container.querySelectorAll('.react-calendar__tile');
65-
const [firstDayTile, secondDayTile] = tiles;
65+
66+
const firstDayTile = tiles[0];
67+
const secondDayTile = tiles[1];
6668

6769
expect(firstDayTile).toHaveClass('firstDayOfTheMonth');
6870
expect(secondDayTile).not.toHaveClass('firstDayOfTheMonth');
@@ -75,9 +77,7 @@ describe('CenturyView', () => {
7577
<CenturyView {...defaultProps} showNeighboringMonth={false} tileContent={tileContent} />,
7678
);
7779

78-
const tiles = container.querySelectorAll('.react-calendar__tile');
79-
const [firstDayTile] = tiles;
80-
80+
const firstDayTile = container.querySelector('.react-calendar__tile');
8181
const firstDayTileContent = firstDayTile.querySelector('.testContent');
8282

8383
expect(firstDayTileContent).toBeInTheDocument();
@@ -103,7 +103,9 @@ describe('CenturyView', () => {
103103
);
104104

105105
const tiles = container.querySelectorAll('.react-calendar__tile');
106-
const [firstDayTile, secondDayTile] = tiles;
106+
107+
const firstDayTile = tiles[0];
108+
const secondDayTile = tiles[1];
107109

108110
const firstDayTileContent = firstDayTile.querySelector('.testContent');
109111
const secondDayTileContent = secondDayTile.querySelector('.testContent');

src/DecadeView.spec.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ describe('DecadeView', () => {
5757
);
5858

5959
const tiles = container.querySelectorAll('.react-calendar__tile');
60-
const [firstDayTile, secondDayTile] = tiles;
60+
61+
const firstDayTile = tiles[0];
62+
const secondDayTile = tiles[1];
6163

6264
expect(firstDayTile).toHaveClass('firstDayOfTheMonth');
6365
expect(secondDayTile).not.toHaveClass('firstDayOfTheMonth');
@@ -96,7 +98,9 @@ describe('DecadeView', () => {
9698
);
9799

98100
const tiles = container.querySelectorAll('.react-calendar__tile');
99-
const [firstDayTile, secondDayTile] = tiles;
101+
102+
const firstDayTile = tiles[0];
103+
const secondDayTile = tiles[1];
100104

101105
const firstDayTileContent = firstDayTile.querySelector('.testContent');
102106
const secondDayTileContent = secondDayTile.querySelector('.testContent');

src/MonthView.spec.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ describe('MonthView', () => {
6565
);
6666

6767
const tiles = container.querySelectorAll('.react-calendar__tile');
68-
const [firstDayTile, secondDayTile] = tiles;
68+
69+
const firstDayTile = tiles[0];
70+
const secondDayTile = tiles[1];
6971

7072
expect(firstDayTile).toHaveClass('firstDayOfTheMonth');
7173
expect(secondDayTile).not.toHaveClass('firstDayOfTheMonth');
@@ -104,7 +106,9 @@ describe('MonthView', () => {
104106
);
105107

106108
const tiles = container.querySelectorAll('.react-calendar__tile');
107-
const [firstDayTile, secondDayTile] = tiles;
109+
110+
const firstDayTile = tiles[0];
111+
const secondDayTile = tiles[1];
108112

109113
const firstDayTileContent = firstDayTile.querySelector('.testContent');
110114
const secondDayTileContent = secondDayTile.querySelector('.testContent');

src/MonthView/WeekNumbers.spec.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ describe('.react-calendar__month-view__weekNumbers', () => {
110110
/>,
111111
);
112112

113-
const children = container.querySelectorAll('button.react-calendar__tile');
113+
const firstChild = container.querySelector('button.react-calendar__tile');
114+
fireEvent.click(firstChild);
114115

115-
fireEvent.click(children[0]);
116116
expect(onClickWeekNumber).toHaveBeenCalledWith(52, new Date(2016, 11, 26), expect.any(Object));
117117
});
118118

@@ -122,9 +122,9 @@ describe('.react-calendar__month-view__weekNumbers', () => {
122122
<WeekNumbers {...defaultProps} calendarType="US" onClickWeekNumber={onClickWeekNumber} />,
123123
);
124124

125-
const children = container.querySelectorAll('button.react-calendar__tile');
125+
const firstChild = container.querySelector('button.react-calendar__tile');
126+
fireEvent.click(firstChild);
126127

127-
fireEvent.click(children[0]);
128128
expect(onClickWeekNumber).toHaveBeenCalledWith(1, new Date(2017, 0, 1), expect.any(Object));
129129
});
130130
});

src/MonthView/Weekdays.spec.jsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,17 @@ describe('Weekdays', () => {
3636
it('renders weekdays with custom weekdays formatting', () => {
3737
const { container } = render(<Weekdays {...defaultProps} formatShortWeekday={() => 'Wkdy'} />);
3838

39-
const weekdays = container.querySelectorAll('.react-calendar__month-view__weekdays__weekday');
40-
const firstWeekday = weekdays[0];
39+
const firstWeekday = container.querySelector('.react-calendar__month-view__weekdays__weekday');
4140

4241
expect(firstWeekday).toHaveTextContent('Wkdy');
4342
});
4443

4544
it('renders weekdays with custom weekdays formatting', () => {
4645
const { container } = render(<Weekdays {...defaultProps} formatWeekday={() => 'Weekday'} />);
4746

48-
const weekdays = container.querySelectorAll('.react-calendar__month-view__weekdays__weekday');
49-
const firstWeekday = weekdays[0];
50-
const abbr = firstWeekday.querySelector('abbr');
47+
const firstWeekday = container.querySelector('.react-calendar__month-view__weekdays__weekday');
48+
const firstWeekdayAbbr = firstWeekday.querySelector('abbr');
5149

52-
expect(abbr).toHaveAccessibleName('Weekday');
50+
expect(firstWeekdayAbbr).toHaveAccessibleName('Weekday');
5351
});
5452
});

src/YearView.spec.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ describe('YearView', () => {
5656
);
5757

5858
const tiles = container.querySelectorAll('.react-calendar__tile');
59-
const [firstDayTile, secondDayTile] = tiles;
59+
60+
const firstDayTile = tiles[0];
61+
const secondDayTile = tiles[1];
6062

6163
expect(firstDayTile).toHaveClass('firstDayOfTheMonth');
6264
expect(secondDayTile).not.toHaveClass('firstDayOfTheMonth');
@@ -95,7 +97,9 @@ describe('YearView', () => {
9597
);
9698

9799
const tiles = container.querySelectorAll('.react-calendar__tile');
98-
const [firstDayTile, secondDayTile] = tiles;
100+
101+
const firstDayTile = tiles[0];
102+
const secondDayTile = tiles[1];
99103

100104
const firstDayTileContent = firstDayTile.querySelector('.testContent');
101105
const secondDayTileContent = secondDayTile.querySelector('.testContent');

0 commit comments

Comments
 (0)