Skip to content

Commit 69605dc

Browse files
committed
add e2e tests
1 parent 24c5462 commit 69605dc

File tree

10 files changed

+67
-34
lines changed

10 files changed

+67
-34
lines changed

src/e2e-app/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ ng_module(
4040
"//src/material-experimental/mdc-input",
4141
"//src/material-experimental/mdc-menu",
4242
"//src/material-experimental/mdc-progress-bar",
43+
"//src/material-experimental/mdc-progress-spinner",
4344
"//src/material-experimental/mdc-radio",
4445
"//src/material-experimental/mdc-slide-toggle",
4546
"//src/material-experimental/mdc-slider",

src/e2e-app/e2e-app/e2e-app-layout.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<a mat-list-item [routerLink]="['mdc-table']">MDC Table</a>
3535
<a mat-list-item [routerLink]="['mdc-tabs']">MDC Tabs</a>
3636
<a mat-list-item [routerLink]="['mdc-progress-bar']">MDC Progress bar</a>
37+
<a mat-list-item [routerLink]="['mdc-progress-spinner']">MDC Progress spinner</a>
3738
</mat-nav-list>
3839

3940
<main>

src/e2e-app/e2e-app/routes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {MdcSliderE2e} from '../mdc-slider/mdc-slider-e2e';
2323
import {MdcTableE2e} from '../mdc-table/mdc-table-e2e';
2424
import {MdcTabsE2e} from '../mdc-tabs/mdc-tabs-e2e';
2525
import {MdcProgressBarE2E} from '../mdc-progress-bar/mdc-progress-bar-e2e';
26+
import {MdcProgressSpinnerE2e} from '../mdc-progress-spinner/mdc-progress-spinner-e2e';
2627
import {MenuE2E} from '../menu/menu-e2e';
2728
import {ProgressBarE2E} from '../progress-bar/progress-bar-e2e';
2829
import {ProgressSpinnerE2E} from '../progress-spinner/progress-spinner-e2e';
@@ -61,6 +62,7 @@ export const E2E_APP_ROUTES: Routes = [
6162
{path: 'mdc-tabs', component: MdcTabsE2e},
6263
{path: 'mdc-table', component: MdcTableE2e},
6364
{path: 'mdc-progress-bar', component: MdcProgressBarE2E},
65+
{path: 'mdc-progress-spinner', component: MdcProgressSpinnerE2e},
6466
{path: 'menu', component: MenuE2E},
6567
{path: 'progress-bar', component: ProgressBarE2E},
6668
{path: 'progress-spinner', component: ProgressSpinnerE2E},

src/e2e-app/main-module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import {TabsE2eModule} from './tabs/tabs-e2e-module';
4040
import {ToolbarE2eModule} from './toolbar/toolbar-e2e-module';
4141
import {VirtualScrollE2eModule} from './virtual-scroll/virtual-scroll-e2e-module';
4242
import {MdcProgressBarE2eModule} from './mdc-progress-bar/mdc-progress-bar-e2e-module';
43+
import {MdcProgressSpinnerE2eModule} from './mdc-progress-spinner/mdc-progress-spinner-module';
4344

4445
@NgModule({
4546
imports: [
@@ -72,6 +73,7 @@ import {MdcProgressBarE2eModule} from './mdc-progress-bar/mdc-progress-bar-e2e-m
7273
MdcTableE2eModule,
7374
MdcTabsE2eModule,
7475
MdcProgressBarE2eModule,
76+
MdcProgressSpinnerE2eModule,
7577
MenuE2eModule,
7678
ProgressBarE2eModule,
7779
ProgressSpinnerE2eModule,
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<mat-progress-spinner [value]="value" [strokeWidth]="strokeWidth"></mat-progress-spinner>
2+
<mat-progress-spinner mode="indeterminate" [diameter]="diameter"></mat-progress-spinner>
3+
<mat-spinner></mat-spinner>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
import {Component} from '@angular/core';
10+
11+
@Component({
12+
selector: 'mdc-progress-spinner-e2e',
13+
templateUrl: 'mdc-progress-spinner-e2e.html'
14+
})
15+
export class MdcProgressSpinnerE2e {
16+
value = 65;
17+
diameter = 37;
18+
strokeWidth = 6;
19+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
import {NgModule} from '@angular/core';
10+
import {MatProgressSpinnerModule} from '@angular/material-experimental/mdc-progress-spinner';
11+
import {MdcProgressSpinnerE2e} from './mdc-progress-spinner-e2e';
12+
13+
@NgModule({
14+
imports: [MatProgressSpinnerModule],
15+
declarations: [MdcProgressSpinnerE2e]
16+
})
17+
export class MdcProgressSpinnerE2eModule {}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {browser, by, element} from 'protractor';
2+
3+
describe('progress-spinner', () => {
4+
beforeEach(async () => await browser.get('/progress-spinner'));
5+
6+
it('should render a determinate progress spinner', async () => {
7+
expect(await element(by.css('mat-progress-spinner')).isPresent()).toBe(true);
8+
});
9+
10+
it('should render an indeterminate progress spinner', async () => {
11+
expect(await element(by.css('mat-progress-spinner[mode="indeterminate"]')).isPresent())
12+
.toBe(true);
13+
});
14+
15+
it('should render a spinner', async () => {
16+
expect(await element(by.css('mat-spinner')).isPresent()).toBe(true);
17+
});
18+
});

src/material-experimental/mdc-progress-spinner/progress-spinner.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
@include mdc-circular-progress-core-styles($query: $mat-base-styles-without-animation-query);
66

77
.mat-mdc-progress-spinner {
8+
// Explicitly set to `block` since the browser defaults custom elements to `inline`.
9+
display: block;
810

911
.mdc-circular-progress {
1012
// MDC circular spinner sets width and height to 48px by default.

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

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -52,40 +52,6 @@ const BASE_SIZE = 100;
5252
*/
5353
const BASE_STROKE_WIDTH = 10;
5454

55-
/** @docs-private */
56-
class ProgressSpinnerAdapter implements MDCCircularProgressAdapter {
57-
constructor(private readonly _delegate: MatProgressSpinner) {
58-
}
59-
60-
addClass(className: string) {
61-
return this._delegate._rootElement.nativeElement.classList.add(className);
62-
}
63-
64-
removeClass(className: string) {
65-
return this._delegate._rootElement.nativeElement.classList.remove(className);
66-
}
67-
68-
hasClass(className: string) {
69-
return this._delegate._rootElement.nativeElement.classList.contains(className);
70-
}
71-
72-
setAttribute(attributeName: string, value: string) {
73-
return this._delegate._rootElement.nativeElement.setAttribute(attributeName, value);
74-
}
75-
76-
removeAttribute(attributeName: string) {
77-
return this._delegate._rootElement.nativeElement.removeAttribute(attributeName);
78-
}
79-
80-
setDeterminateCircleAttribute(attributeName: string, value: string) {
81-
return this._delegate._determinateCircle.nativeElement.setAttribute(attributeName, value);
82-
}
83-
84-
getDeterminateCircleAttribute(attributeName: string) {
85-
return this._delegate._determinateCircle.nativeElement.getAttribute(attributeName);
86-
}
87-
}
88-
8955
@Component({
9056
selector: 'mat-progress-spinner, mat-spinner',
9157
exportAs: 'matProgressSpinner',
@@ -121,6 +87,8 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements
12187
/** The element of the determinate spinner. */
12288
@ViewChild('determinateSpinner') _determinateCircle: ElementRef<HTMLElement>;
12389

90+
/** Adapter used by MDC to interact with the DOM. */
91+
// TODO: switch to class when MDC removes object spread in foundation
12492
private _adapter: MDCCircularProgressAdapter = {
12593
addClass: (className: string) => this._rootElement.nativeElement.classList.add(className),
12694
hasClass: (className: string) => this._rootElement.nativeElement.classList.contains(className),

0 commit comments

Comments
 (0)