Skip to content

Commit a8a20a1

Browse files
committed
doc strings
1 parent 1131d8c commit a8a20a1

File tree

2 files changed

+66
-2
lines changed

2 files changed

+66
-2
lines changed

src/material-experimental/mdc-checkbox/harness/checkbox-harness.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ import {coerceBooleanProperty} from '@angular/cdk/coercion';
1616
export class MatCheckboxHarness extends ComponentHarness {
1717
static hostSelector = 'mat-checkbox';
1818

19-
static with(options: {label: string | RegExp}): HarnessPredicate<MatCheckboxHarness> {
19+
/**
20+
* Gets a `HarnessPredicate` that can be used to search for a checkbox with specific attributes.
21+
* @param options Options for narrowing the search:
22+
* - `label` finds a checkbox with specific label text.
23+
* @return a `HarnessPredicate` configured with the given options.
24+
*/
25+
static with(options: {label?: string | RegExp} = {}): HarnessPredicate<MatCheckboxHarness> {
2026
return new HarnessPredicate(MatCheckboxHarness)
2127
.addOption('label', options.label,
2228
(harness, label) => HarnessPredicate.stringMatches(harness.getLabelText(), label));
@@ -25,69 +31,95 @@ export class MatCheckboxHarness extends ComponentHarness {
2531
private _label = this.locatorFor('.mat-checkbox-label');
2632
private _input = this.locatorFor('input');
2733

34+
/** Gets a boolean promise indicating if the checkbox is checked. */
2835
async isChecked(): Promise<boolean> {
2936
const checked = (await this._input()).getAttribute('checked');
3037
return coerceBooleanProperty(await checked);
3138
}
3239

40+
/** Gets a boolean promise indicating if the checkbox is in an indeterminate state. */
3341
async isIndeterminate(): Promise<boolean> {
3442
const indeterminate = (await this._input()).getAttribute('indeterminate');
3543
return coerceBooleanProperty(await indeterminate);
3644
}
3745

46+
/** Gets a boolean promise indicating if the checkbox is disabled. */
3847
async isDisabled(): Promise<boolean> {
3948
const disabled = (await this._input()).getAttribute('disabled');
4049
return coerceBooleanProperty(await disabled);
4150
}
4251

52+
/** Gets a boolean promise indicating if the checkbox is required. */
4353
async isRequired(): Promise<boolean> {
4454
const required = (await this._input()).getAttribute('required');
4555
return coerceBooleanProperty(await required);
4656
}
4757

58+
/** Gets a boolean promise indicating if the checkbox is valid. */
4859
async isValid(): Promise<boolean> {
4960
const invalid = (await this.host()).hasClass('ng-invalid');
5061
return !(await invalid);
5162
}
5263

64+
/** Gets a promise for the checkbox's name. */
5365
async getName(): Promise<string | null> {
5466
return (await this._input()).getAttribute('name');
5567
}
5668

69+
/** Gets a promise for the checkbox's value. */
5770
async getValue(): Promise<string | null> {
5871
return (await this._input()).getAttribute('value');
5972
}
6073

74+
/** Gets a promise for the checkbox's aria-label. */
6175
async getAriaLabel(): Promise<string | null> {
6276
return (await this._input()).getAttribute('aria-label');
6377
}
6478

79+
/** Gets a promise for the checkbox's aria-labelledby. */
6580
async getAriaLabelledby(): Promise<string | null> {
6681
return (await this._input()).getAttribute('aria-labelledby');
6782
}
6883

84+
/** Gets a promise for the checkbox's label text. */
6985
async getLabelText(): Promise<string> {
7086
return (await this._label()).text();
7187
}
7288

89+
/** Focuses the checkbox and returns a void promise that indicates when the action is complete. */
7390
async foucs(): Promise<void> {
7491
return (await this._input()).focus();
7592
}
7693

94+
/** Blurs the checkbox and returns a void promise that indicates when the action is complete. */
7795
async blur(): Promise<void> {
7896
return (await this._input()).blur();
7997
}
8098

99+
/**
100+
* Toggle the checked state of the checkbox and returns a void promise that indicates when the
101+
* action is complete.
102+
*/
81103
async toggle(): Promise<void> {
82104
return (await this._input()).click();
83105
}
84106

107+
/**
108+
* Puts the checkbox in a checked state by toggling it if it is currently unchecked, or doing
109+
* nothing if it is already checked. Returns a void promise that indicates when the action is
110+
* complete.
111+
*/
85112
async check(): Promise<void> {
86113
if (!(await this.isChecked())) {
87114
await this.toggle();
88115
}
89116
}
90117

118+
/**
119+
* Puts the checkbox in an unchecked state by toggling it if it is currently checked, or doing
120+
* nothing if it is already unchecked. Returns a void promise that indicates when the action is
121+
* complete.
122+
*/
91123
async uncheck(): Promise<void> {
92124
if (await this.isChecked()) {
93125
await this.toggle();

src/material-experimental/mdc-checkbox/harness/mdc-checkbox-harness.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ import {coerceBooleanProperty} from '@angular/cdk/coercion';
1616
export class MatCheckboxHarness extends ComponentHarness {
1717
static hostSelector = 'mat-checkbox';
1818

19-
static with(options: {label: string | RegExp}): HarnessPredicate<MatCheckboxHarness> {
19+
/**
20+
* Gets a `HarnessPredicate` that can be used to search for a checkbox with specific attributes.
21+
* @param options Options for narrowing the search:
22+
* - `label` finds a checkbox with specific label text.
23+
* @return a `HarnessPredicate` configured with the given options.
24+
*/
25+
static with(options: {label?: string | RegExp} = {}): HarnessPredicate<MatCheckboxHarness> {
2026
return new HarnessPredicate(MatCheckboxHarness)
2127
.addOption('label', options.label,
2228
(harness, label) => HarnessPredicate.stringMatches(harness.getLabelText(), label));
@@ -25,69 +31,95 @@ export class MatCheckboxHarness extends ComponentHarness {
2531
private _label = this.locatorFor('label');
2632
private _input = this.locatorFor('input');
2733

34+
/** Gets a boolean promise indicating if the checkbox is checked. */
2835
async isChecked(): Promise<boolean> {
2936
const checked = (await this._input()).getAttribute('checked');
3037
return coerceBooleanProperty(await checked);
3138
}
3239

40+
/** Gets a boolean promise indicating if the checkbox is in an indeterminate state. */
3341
async isIndeterminate(): Promise<boolean> {
3442
const indeterminate = (await this._input()).getAttribute('indeterminate');
3543
return coerceBooleanProperty(await indeterminate);
3644
}
3745

46+
/** Gets a boolean promise indicating if the checkbox is disabled. */
3847
async isDisabled(): Promise<boolean> {
3948
const disabled = (await this._input()).getAttribute('disabled');
4049
return coerceBooleanProperty(await disabled);
4150
}
4251

52+
/** Gets a boolean promise indicating if the checkbox is required. */
4353
async isRequired(): Promise<boolean> {
4454
const required = (await this._input()).getAttribute('required');
4555
return coerceBooleanProperty(await required);
4656
}
4757

58+
/** Gets a boolean promise indicating if the checkbox is valid. */
4859
async isValid(): Promise<boolean> {
4960
const invalid = (await this.host()).hasClass('ng-invalid');
5061
return !(await invalid);
5162
}
5263

64+
/** Gets a promise for the checkbox's name. */
5365
async getName(): Promise<string | null> {
5466
return (await this._input()).getAttribute('name');
5567
}
5668

69+
/** Gets a promise for the checkbox's value. */
5770
async getValue(): Promise<string | null> {
5871
return (await this._input()).getAttribute('value');
5972
}
6073

74+
/** Gets a promise for the checkbox's aria-label. */
6175
async getAriaLabel(): Promise<string | null> {
6276
return (await this._input()).getAttribute('aria-label');
6377
}
6478

79+
/** Gets a promise for the checkbox's aria-labelledby. */
6580
async getAriaLabelledby(): Promise<string | null> {
6681
return (await this._input()).getAttribute('aria-labelledby');
6782
}
6883

84+
/** Gets a promise for the checkbox's label text. */
6985
async getLabelText(): Promise<string> {
7086
return (await this._label()).text();
7187
}
7288

89+
/** Focuses the checkbox and returns a void promise that indicates when the action is complete. */
7390
async foucs(): Promise<void> {
7491
return (await this._input()).focus();
7592
}
7693

94+
/** Blurs the checkbox and returns a void promise that indicates when the action is complete. */
7795
async blur(): Promise<void> {
7896
return (await this._input()).blur();
7997
}
8098

99+
/**
100+
* Toggle the checked state of the checkbox and returns a void promise that indicates when the
101+
* action is complete.
102+
*/
81103
async toggle(): Promise<void> {
82104
return (await this._input()).click();
83105
}
84106

107+
/**
108+
* Puts the checkbox in a checked state by toggling it if it is currently unchecked, or doing
109+
* nothing if it is already checked. Returns a void promise that indicates when the action is
110+
* complete.
111+
*/
85112
async check(): Promise<void> {
86113
if (!(await this.isChecked())) {
87114
await this.toggle();
88115
}
89116
}
90117

118+
/**
119+
* Puts the checkbox in an unchecked state by toggling it if it is currently checked, or doing
120+
* nothing if it is already unchecked. Returns a void promise that indicates when the action is
121+
* complete.
122+
*/
91123
async uncheck(): Promise<void> {
92124
if (await this.isChecked()) {
93125
await this.toggle();

0 commit comments

Comments
 (0)