Skip to content

Commit 0a73002

Browse files
committed
Titlecase naming
1 parent 8c6f321 commit 0a73002

13 files changed

+68
-64
lines changed

src/roles/all.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
export * from './tabs';
12
export * from './button';
23
export * from './checkbox';
3-
export * from './tabs';
4+
export * from './textbox';
5+
export * from './listbox';
6+
export * from './combobox';
7+
export * from './search';
48
export * from './menu';

src/roles/calendar.test.tsx

+21-21
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Calendar } from './calendar';
33
import { prettyDOM, render } from '@testing-library/react';
44
import user from '@testing-library/user-event';
55
import '@testing-library/jest-dom';
6-
import { CalendarSpectrum } from './Calendar-spectrum';
6+
import { CalendarSpectrum } from './calendar-spectrum';
77
import { screenTest } from '../screen';
88

99
function freshFn() {
@@ -22,50 +22,50 @@ describe('Calendar', () => {
2222
});
2323

2424
it('has previous button', () => {
25-
expect(screenTest(Calendar.previousButton())).toBeVisible();
25+
expect(screenTest(Calendar.PreviousButton())).toBeVisible();
2626
});
2727

2828
it('can click previous button', async () => {
29-
await screenTest.wait(Calendar.previousButton().click);
29+
await screenTest.wait(Calendar.PreviousButton().click);
3030
expect(
31-
await screenTest.wait(Calendar.grid('Audition Date, January 2020'))
31+
await screenTest.wait(Calendar.Grid('Audition Date, January 2020'))
3232
).toBeVisible();
3333
});
3434

3535
it('has next button', () => {
3636
// Spectrum has two Next button, one for the next month, one for tabbing.
37-
expect(screenTest(Calendar.nextButton().all)[0]).toBeVisible();
37+
expect(screenTest(Calendar.NextButton().all)[0]).toBeVisible();
3838
});
3939

4040
it('has grid', () => {
41-
expect(screenTest(Calendar.grid())).toBeVisible();
41+
expect(screenTest(Calendar.Grid())).toBeVisible();
4242
});
4343

4444
it('has named grid', () => {
4545
expect(
46-
screenTest(Calendar.grid('Audition Date, February 2020'))
46+
screenTest(Calendar.Grid('Audition Date, February 2020'))
4747
).toBeVisible();
4848
});
4949

5050
it('has week rows', () => {
51-
expect(screenTest(Calendar.weekRow().all)).toHaveLength(5);
51+
expect(screenTest(Calendar.WeekRow().all)).toHaveLength(5);
5252
});
5353

5454
it('has day gridcells', () => {
55-
expect(screenTest(Calendar.dayGridCell().all)).toHaveLength(5 * 7);
55+
expect(screenTest(Calendar.DayGridCell().all)).toHaveLength(5 * 7);
5656
});
5757

5858
it('has selected day gridcell', () => {
59-
const selectedDay = screenTest(Calendar.dayGridCell().selected);
59+
const selectedDay = screenTest(Calendar.DayGridCell().selected);
6060
expect(
61-
screenTest(Calendar.dayButton(/February 3, 2020/), selectedDay)
61+
screenTest(Calendar.DayButton(/February 3, 2020/), selectedDay)
6262
).toBeVisible();
6363
});
6464

6565
describe.skip('when particular day is clicked', () => {
6666
beforeEach(async () => {
67-
console.log(prettyDOM(screenTest(Calendar.grid())));
68-
await screenTest.wait(Calendar.dayButton('20 February 2020').click);
67+
console.log(prettyDOM(screenTest(Calendar.Grid())));
68+
await screenTest.wait(Calendar.DayButton('20 February 2020').click);
6969
});
7070

7171
it('dispatches', () => {
@@ -81,43 +81,43 @@ describe('Calendar', () => {
8181
});
8282

8383
it('focuses on selected day', () => {
84-
const selectedDay = screenTest(Calendar.dayGridCell().selected);
85-
expect(screenTest(Calendar.dayButton(), selectedDay)).toHaveFocus();
84+
const selectedDay = screenTest(Calendar.DayGridCell().selected);
85+
expect(screenTest(Calendar.DayButton(), selectedDay)).toHaveFocus();
8686
});
8787

8888
it('can go left', async () => {
8989
await user.keyboard('{ArrowLeft}');
9090
expect(
91-
screenTest(Calendar.dayButton(/February 2, 2020/))
91+
screenTest(Calendar.DayButton(/February 2, 2020/))
9292
).toHaveFocus();
9393
});
9494

9595
it('can go right', async () => {
9696
await user.keyboard('{ArrowRight}');
9797
expect(
98-
screenTest(Calendar.dayButton(/February 4, 2020/))
98+
screenTest(Calendar.DayButton(/February 4, 2020/))
9999
).toHaveFocus();
100100
});
101101

102102
it('can select left with Enter key', async () => {
103103
await user.keyboard('{ArrowLeft}{Enter}');
104-
const selectedDay = screenTest(Calendar.dayGridCell().selected);
104+
const selectedDay = screenTest(Calendar.DayGridCell().selected);
105105
expect(
106-
screenTest(Calendar.dayButton(/February 2, 2020/), selectedDay)
106+
screenTest(Calendar.DayButton(/February 2, 2020/), selectedDay)
107107
).toHaveFocus();
108108
});
109109

110110
it('can select right with Enter key', async () => {
111111
await user.keyboard('{ArrowRight}{Enter}');
112112
expect(
113-
screenTest(Calendar.dayButton(/February 4, 2020/))
113+
screenTest(Calendar.DayButton(/February 4, 2020/))
114114
).toHaveFocus();
115115
});
116116

117117
it('focuses next week after pressing right arrow 7 times', async () => {
118118
await user.keyboard(new Array(7).fill('{ArrowRight}').join(''));
119119
expect(
120-
screenTest(Calendar.dayButton(/February 10, 2020/))
120+
screenTest(Calendar.DayButton(/February 10, 2020/))
121121
).toHaveFocus();
122122
});
123123
});

src/roles/calendar.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@ import { role, roleSelectable } from './shared';
33
export const Calendar = Object.assign(
44
{},
55
{
6-
previousButton(name: string | RegExp = /previous/i) {
6+
PreviousButton(name: string | RegExp = /previous/i) {
77
return role<{ click: true }>('button', name);
88
},
9-
nextButton(name: string | RegExp = /next/i) {
9+
NextButton(name: string | RegExp = /next/i) {
1010
return role<{ click: true }>('button', name);
1111
},
12-
grid(name?: string | RegExp) {
12+
Grid(name?: string | RegExp) {
1313
return role('grid', name);
1414
},
15-
weekRow(name?: string | RegExp) {
15+
WeekRow(name?: string | RegExp) {
1616
return role('row', name);
1717
},
18-
dayGridCell(name?: string | RegExp) {
18+
DayGridCell(name?: string | RegExp) {
1919
return roleSelectable('gridcell', name);
2020
},
21-
dayButton(name?: string | RegExp) {
21+
DayButton(name?: string | RegExp) {
2222
return role<{ click: true }>('button', name);
2323
},
2424
}

src/roles/combobox.test.tsx

+16-16
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Combobox } from './combobox';
88
import { ComboboxSpectrum } from './combobox-spectrum';
99

1010
describe('Combobox', () => {
11-
describe.each([['<ComboboxHeadlessUI>', <ComboboxHeadlessUI />]])(
11+
describe.each([['@headlessui/react', <ComboboxHeadlessUI />]])(
1212
'%s',
1313
(_displayName, el) => {
1414
beforeEach(() => {
@@ -36,31 +36,31 @@ describe('Combobox', () => {
3636
test('tabThenDownArrow', async () => {
3737
await Combobox.Interactions(user).tabThenDownArrow();
3838
waitFor(() => {
39-
expect(screenTest(Combobox.popupListbox())).toBeVisible();
39+
expect(screenTest(Combobox.PopupListbox())).toBeVisible();
4040
});
4141
});
4242

4343
test('tabThenDownArrow + escape', async () => {
4444
await Combobox.Interactions(user).tabThenDownArrow();
4545
await Combobox.Interactions(user).escape();
46-
expect(screenTest(Combobox.popupListbox.all)).toHaveLength(0);
46+
expect(screenTest(Combobox.PopupListbox.all)).toHaveLength(0);
4747
});
4848
});
4949

5050
describe('when user tabs and presses the down arrow', () => {
5151
beforeEach(() => user.keyboard('{Tab}{Down}'));
5252

5353
it('renders listbox', () => {
54-
expect(screenTest(Combobox.popupListbox())).toBeVisible();
54+
expect(screenTest(Combobox.PopupListbox())).toBeVisible();
5555
});
5656

5757
it('renders 1 listbox', () => {
58-
expect(screenTest(Combobox.popupListbox.all)).toHaveLength(1);
58+
expect(screenTest(Combobox.PopupListbox.all)).toHaveLength(1);
5959
});
6060

6161
it('has 5 options', async () => {
6262
await waitFor(() => {
63-
expect(screenTest(Combobox.popupListbox.option().all)).toHaveLength(
63+
expect(screenTest(Combobox.PopupListbox.Option().all)).toHaveLength(
6464
5
6565
);
6666
});
@@ -85,47 +85,47 @@ describe('Combobox', () => {
8585
});
8686

8787
describe('Combobox.Button', () => {
88-
describe.each([['<ComboboxSpectrum>', <ComboboxSpectrum />]])(
88+
describe.each([['@adobe/react-spectrum', <ComboboxSpectrum />]])(
8989
'%s',
9090
(_displayName, el) => {
9191
beforeEach(() => {
9292
render(el);
9393
});
9494

9595
it('renders button', () => {
96-
expect(screenTest(Combobox.button())).toBeVisible();
96+
expect(screenTest(Combobox.Button())).toBeVisible();
9797
});
9898

9999
it('renders named button', () => {
100100
expect(
101-
screenTest(Combobox.button('Person Durward Reynolds'))
101+
screenTest(Combobox.Button('Person Durward Reynolds'))
102102
).toBeVisible();
103103
});
104104

105105
it('has selected person as name', () => {
106-
expect(screenTest(Combobox.button())).toHaveAccessibleName(
106+
expect(screenTest(Combobox.Button())).toHaveAccessibleName(
107107
expect.stringContaining('Durward Reynolds')
108108
);
109109
});
110110

111111
describe('.Interactions', () => {
112112
test('tab', async () => {
113113
await Combobox.Interactions(user).tab();
114-
expect(screenTest(Combobox.button())).toHaveFocus();
114+
expect(screenTest(Combobox.Button())).toHaveFocus();
115115
});
116116

117117
test.skip('tabThenDownArrow', async () => {
118118
await Combobox.Interactions(user).tabThenDownArrow();
119119
await waitFor(() => {
120-
expect(screenTest(Combobox.popupListbox())).toBeVisible();
120+
expect(screenTest(Combobox.PopupListbox())).toBeVisible();
121121
});
122122
});
123123

124124
test('tabThenDownArrow + escape', async () => {
125125
await Combobox.Interactions(user).tabThenDownArrow();
126126
await Combobox.Interactions(user).escape();
127127
waitFor(() => {
128-
expect(screenTest(Combobox.popupListbox.all)).toHaveLength(0);
128+
expect(screenTest(Combobox.PopupListbox.all)).toHaveLength(0);
129129
});
130130
});
131131
});
@@ -134,16 +134,16 @@ describe('Combobox.Button', () => {
134134
beforeEach(() => user.keyboard('{Tab}{Down}'));
135135

136136
it('renders listbox', () => {
137-
expect(screenTest(Combobox.popupListbox())).toBeVisible();
137+
expect(screenTest(Combobox.PopupListbox())).toBeVisible();
138138
});
139139

140140
it('renders 1 listbox', () => {
141-
expect(screenTest(Combobox.popupListbox.all)).toHaveLength(1);
141+
expect(screenTest(Combobox.PopupListbox.all)).toHaveLength(1);
142142
});
143143

144144
it('has 5 options', async () => {
145145
await waitFor(() => {
146-
expect(screenTest(Combobox.popupListbox.option().all)).toHaveLength(
146+
expect(screenTest(Combobox.PopupListbox.Option().all)).toHaveLength(
147147
5
148148
);
149149
});

src/roles/combobox.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ export const Combobox = Object.assign(combobox, {
1515
get all() {
1616
return role('combobox').all;
1717
},
18-
get popupListbox() {
18+
get PopupListbox() {
1919
return Listbox;
2020
},
21-
get button() {
21+
get Button() {
2222
return Button;
2323
},
2424
// TODO: or Scripts()?

src/roles/listbox.test.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ describe('Listbox', () => {
1818
});
1919

2020
it('renders button', () => {
21-
expect(screenTest(Button(/^Choose/))).toBeVisible();
21+
expect(screenTest(Button(/\bChoose\b/))).toBeVisible();
2222
});
2323

2424
describe('when opening', () => {
2525
// screenTest.click(Button(/^Choose/))
2626
// screenTest.user.clicks(Button(/^Choose/))
2727
// screenTest._clicks_(Button(/^Choose/))
28-
beforeEach(() => user.click(screenTest(Button(/^Choose/))));
28+
beforeEach(() => user.click(screenTest(Button(/\bChoose\b/))));
2929

3030
it('renders labelled listbox', () => {
3131
expect(screenTest(Listbox('Choose'))).toBeVisible();
@@ -38,7 +38,7 @@ describe('Listbox', () => {
3838
it.skip('has 3 options', async () => {
3939
// const el = screenTest(Listbox());
4040
await waitFor(() => {
41-
expect(screenTest(Listbox.option().all)).toHaveLength(3);
41+
expect(screenTest(Listbox.Option().all)).toHaveLength(3);
4242
});
4343
});
4444
});

src/roles/listbox.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const Listbox = Object.assign(listbox, {
1111
get all() {
1212
return role('listbox').all;
1313
},
14-
option(name?: string | RegExp) {
14+
Option(name?: string | RegExp) {
1515
return roleSelectable('option', name);
1616
},
1717
});

src/roles/menu.test.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@ describe('Menu', () => {
3434
});
3535

3636
it('renders 3 menu items', () => {
37-
expect(screenTest(Menu.item().all)).toHaveLength(3);
37+
expect(screenTest(Menu.Item().all)).toHaveLength(3);
3838
});
3939

4040
it('renders 3 menu items: Cut, Copy, Paste', () => {
41-
const [first, second, third] = screenTest(Menu.item().all);
41+
const [first, second, third] = screenTest(Menu.Item().all);
4242
expect(first).toHaveAccessibleName('Cut');
4343
expect(second).toHaveAccessibleName('Copy');
4444
expect(third).toHaveAccessibleName('Paste');
4545
});
4646

4747
describe('when clicking on Cut item', () => {
4848
beforeEach(async () => {
49-
await user.click(screenTest(Menu.item('Cut')));
49+
await user.click(screenTest(Menu.Item('Cut')));
5050
});
5151

5252
it('calls select with cut', () => {
@@ -56,7 +56,7 @@ describe('Menu', () => {
5656

5757
describe('when clicking on Copy item', () => {
5858
beforeEach(async () => {
59-
await user.click(screenTest(Menu.item('Copy')));
59+
await user.click(screenTest(Menu.Item('Copy')));
6060
});
6161

6262
it('calls select with copy', () => {
@@ -66,7 +66,7 @@ describe('Menu', () => {
6666

6767
describe('when clicking on Paste item', () => {
6868
beforeEach(async () => {
69-
await user.click(screenTest(Menu.item('Paste')));
69+
await user.click(screenTest(Menu.Item('Paste')));
7070
});
7171

7272
it('calls select with paste', () => {

src/roles/menu.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const Menu = Object.assign(
1111
get all() {
1212
return role('menu').all;
1313
},
14-
item(name?: string | RegExp) {
14+
Item(name?: string | RegExp) {
1515
return role('menuitem', name);
1616
},
1717
}

src/roles/search.test.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('Checkbox', () => {
2929
});
3030

3131
it('has search box', () => {
32-
expect(screenTest(Search.box())).toBeVisible();
32+
expect(screenTest(Search.Box())).toBeVisible();
3333
});
3434

3535
describe('when user submit search', () => {

src/roles/search.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const Search = Object.assign(
88
get all() {
99
return role('search').all;
1010
},
11-
box(name?: string | RegExp) {
11+
Box(name?: string | RegExp) {
1212
return role('searchbox', name);
1313
},
1414
}

0 commit comments

Comments
 (0)