Skip to content

Commit 0f02d98

Browse files
committed
Add support to getDiameter and getStrokeWidth in MatProgressSpinnerHarness
Adding missing attributes in MatProgressSpinnerHarness
1 parent 1c19be5 commit 0f02d98

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

src/material/progress-spinner/progress-spinner.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ const BASE_STROKE_WIDTH = 10;
8686
'[attr.aria-valuemin]': '0',
8787
'[attr.aria-valuemax]': '100',
8888
'[attr.aria-valuenow]': 'mode === "determinate" ? value : null',
89-
'[attr.mode]': 'mode',
89+
'[attr.data-mat-progress-spinner-mode]': 'mode',
90+
'[attr.data-mat-progress-spinner-diameter]': 'diameter',
91+
'[attr.data-mat-progress-spinner-strokeWidth]': 'strokeWidth',
9092
},
9193
templateUrl: 'progress-spinner.html',
9294
styleUrl: 'progress-spinner.css',

src/material/progress-spinner/testing/progress-spinner-harness.spec.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,44 @@ describe('MatProgressSpinnerHarness', () => {
4040
expect(await indeterminate.getMode()).toBe('indeterminate');
4141
expect(await impliedIndeterminate.getMode()).toBe('indeterminate');
4242
});
43+
44+
it('should get the diameter', async () => {
45+
const withAttributs =
46+
await loader.getHarness(MatProgressSpinnerHarness.with({selector: '.with-attributs'}));
47+
expect(await withAttributs.getDiameter()).toBe(30);
48+
fixture.componentInstance.diameter.set(20);
49+
expect(await withAttributs.getDiameter()).toBe(20);
50+
});
51+
52+
it('should get the strokeWidth', async () => {
53+
const withAttributs =
54+
await loader.getHarness(MatProgressSpinnerHarness.with({selector: '.with-attributs'}));
55+
expect(await withAttributs.getStrokeWidth()).toBe(3);
56+
fixture.componentInstance.strokeWidth.set(5);
57+
expect(await withAttributs.getStrokeWidth()).toBe(5);
58+
});
59+
60+
it('should get the strokeWidth when undefined', async () => {
61+
const withAttributs =
62+
await loader.getHarness(MatProgressSpinnerHarness.with({selector: '.with-attributs'}));
63+
expect(await withAttributs.getStrokeWidth()).toBe(3);
64+
fixture.componentInstance.diameter.set(20);
65+
expect(await withAttributs.getStrokeWidth()).toBe(2);
66+
});
4367
});
4468

4569
@Component({
4670
template: `
4771
<mat-progress-spinner mode="determinate" [value]="value()"></mat-progress-spinner>
4872
<mat-progress-spinner mode="indeterminate"></mat-progress-spinner>
4973
<mat-spinner></mat-spinner>
74+
<mat-spinner class="with-attributs" [diameter]="diameter()" [strokeWidth]="strokeWidth()"></mat-spinner>
5075
`,
5176
standalone: true,
5277
imports: [MatProgressSpinnerModule],
5378
})
5479
class ProgressSpinnerHarnessTest {
5580
value = signal(0);
81+
diameter = signal(30);
82+
strokeWidth = signal(3);
5683
}

src/material/progress-spinner/testing/progress-spinner-harness.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,19 @@ export class MatProgressSpinnerHarness extends ComponentHarness {
4242

4343
/** Gets the progress spinner's mode. */
4444
async getMode(): Promise<ProgressSpinnerMode> {
45-
const modeAttr = (await this.host()).getAttribute('mode');
45+
const modeAttr = (await this.host()).getAttribute('data-mat-progress-spinner-mode');
4646
return (await modeAttr) as ProgressSpinnerMode;
4747
}
48+
49+
/** Gets the progress spinner's diameter. */
50+
async getDiameter(): Promise<number | null> {
51+
const diameterAttr = (await this.host()).getAttribute('data-mat-progress-spinner-diameter');
52+
return (await diameterAttr) as ProgressSpinnerMode;
53+
}
54+
55+
/** Gets the progress spinner's strokeWidth. */
56+
async getStrokeWidth(): Promise<number | null> {
57+
const strokeWidthAttr = (await this.host()).getAttribute('data-mat-progress-spinner-strokeWidth');
58+
return (await strokeWidthAttr) as ProgressSpinnerMode;
59+
}
4860
}

0 commit comments

Comments
 (0)