Skip to content

Commit 4c927e9

Browse files
committed
test(aria/grid): generate additional methods and tests for Grid harness
1 parent 597b801 commit 4c927e9

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

goldens/aria/grid/testing/index.api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ export class GridCellHarness extends ContentContainerComponentHarness {
1717
getText(): Promise<string>;
1818
// (undocumented)
1919
static hostSelector: string;
20+
isActive(): Promise<boolean>;
2021
isDisabled(): Promise<boolean>;
22+
isFocused(): Promise<boolean>;
2123
isSelected(): Promise<boolean>;
2224
static with(options?: GridCellHarnessFilters): HarnessPredicate<GridCellHarness>;
2325
}

src/aria/grid/testing/grid-harness.spec.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,19 @@ describe('Grid Harness', () => {
9797
const rows = await loader.getAllHarnesses(GridRowHarness);
9898
expect(await rows[0].getCellTextByIndex()).toEqual(['Cell 1.1', 'Cell 1.2']);
9999
});
100+
101+
it('reports the active state of a cell', async () => {
102+
const cell = await loader.getHarness(GridCellHarness.with({text: 'Cell 1.1'}));
103+
expect(await cell.isActive()).toBeTrue();
104+
});
105+
106+
it('reports the focused state of a cell', async () => {
107+
const cell = await loader.getHarness(GridCellHarness.with({text: 'Cell 1.1'}));
108+
expect(await cell.isFocused()).toBeFalse();
109+
110+
await cell.focus();
111+
expect(await cell.isFocused()).toBeTrue();
112+
});
100113
});
101114

102115
@Component({

src/aria/grid/testing/grid-harness.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,18 @@ export class GridCellHarness extends ContentContainerComponentHarness {
7979
const host = await this.host();
8080
return host.blur();
8181
}
82+
83+
/** Whether the cell is active. */
84+
async isActive(): Promise<boolean> {
85+
const host = await this.host();
86+
return (await host.getAttribute('data-active')) === 'true';
87+
}
88+
89+
/** Whether the cell is focused. */
90+
async isFocused(): Promise<boolean> {
91+
const host = await this.host();
92+
return host.isFocused();
93+
}
8294
}
8395

8496
/** Harness for interacting with a standard ngGridRow in tests. */

0 commit comments

Comments
 (0)