Skip to content

Commit

Permalink
feat(stepper): add test harness (#20092)
Browse files Browse the repository at this point in the history
Adds test harnesses for the stepper-related components.
  • Loading branch information
crisbeto committed Aug 20, 2020
1 parent fe14d88 commit f343ded
Show file tree
Hide file tree
Showing 13 changed files with 750 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/material/config.bzl
Expand Up @@ -55,6 +55,7 @@ entryPoints = [
"sort",
"sort/testing",
"stepper",
"stepper/testing",
"table",
"table/testing",
"tabs",
Expand Down
5 changes: 3 additions & 2 deletions src/material/stepper/step-header.html
Expand Up @@ -19,8 +19,9 @@
[class.mat-step-label-selected]="selected"
[class.mat-step-label-error]="state == 'error'">
<!-- If there is a label template, use it. -->
<ng-container *ngIf="_templateLabel()" [ngTemplateOutlet]="_templateLabel()!.template">
</ng-container>
<div class="mat-step-text-label" *ngIf="_templateLabel()">
<ng-container [ngTemplateOutlet]="_templateLabel()!.template"></ng-container>
</div>
<!-- If there is no label template, fall back to the text label. -->
<div class="mat-step-text-label" *ngIf="_stringLabel()">{{label}}</div>

Expand Down
2 changes: 2 additions & 0 deletions src/material/stepper/stepper-button.ts
Expand Up @@ -13,6 +13,7 @@ import {Directive} from '@angular/core';
@Directive({
selector: 'button[matStepperNext]',
host: {
'class': 'mat-stepper-next',
'[type]': 'type',
},
inputs: ['type']
Expand All @@ -24,6 +25,7 @@ export class MatStepperNext extends CdkStepperNext {
@Directive({
selector: 'button[matStepperPrevious]',
host: {
'class': 'mat-stepper-previous',
'[type]': 'type',
},
inputs: ['type']
Expand Down
53 changes: 53 additions & 0 deletions src/material/stepper/testing/BUILD.bazel
@@ -0,0 +1,53 @@
load("//tools:defaults.bzl", "ng_test_library", "ng_web_test_suite", "ts_library")

package(default_visibility = ["//visibility:public"])

ts_library(
name = "testing",
srcs = glob(
["**/*.ts"],
exclude = ["**/*.spec.ts"],
),
module_name = "@angular/material/stepper/testing",
deps = [
"//src/cdk/testing",
],
)

filegroup(
name = "source-files",
srcs = glob(["**/*.ts"]),
)

ng_test_library(
name = "harness_tests_lib",
srcs = ["shared.spec.ts"],
deps = [
":testing",
"//src/cdk/stepper",
"//src/cdk/testing",
"//src/cdk/testing/private",
"//src/cdk/testing/testbed",
"//src/material/stepper",
"@npm//@angular/forms",
"@npm//@angular/platform-browser",
],
)

ng_test_library(
name = "unit_tests_lib",
srcs = glob(
["**/*.spec.ts"],
exclude = ["shared.spec.ts"],
),
deps = [
":harness_tests_lib",
":testing",
"//src/material/stepper",
],
)

ng_web_test_suite(
name = "unit_tests",
deps = [":unit_tests_lib"],
)
9 changes: 9 additions & 0 deletions src/material/stepper/testing/index.ts
@@ -0,0 +1,9 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/

export * from './public-api';
12 changes: 12 additions & 0 deletions src/material/stepper/testing/public-api.ts
@@ -0,0 +1,12 @@
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/

export * from './stepper-harness';
export * from './step-harness';
export * from './step-harness-filters';
export * from './stepper-button-harnesses';

0 comments on commit f343ded

Please sign in to comment.