Skip to content

Commit

Permalink
feat(progress): move harnesses out of experimental (#17115)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalerba authored and jelbourn committed Sep 17, 2019
1 parent fe6b413 commit 26df035
Show file tree
Hide file tree
Showing 17 changed files with 201 additions and 81 deletions.
29 changes: 0 additions & 29 deletions src/material-experimental/mdc-progress-bar/BUILD.bazel

This file was deleted.

29 changes: 0 additions & 29 deletions src/material-experimental/mdc-progress-spinner/BUILD.bazel

This file was deleted.

46 changes: 46 additions & 0 deletions src/material/progress-bar/testing/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package(default_visibility = ["//visibility:public"])

load("//tools:defaults.bzl", "ng_module", "ng_test_library", "ng_web_test_suite")

ng_module(
name = "testing",
srcs = glob(
["**/*.ts"],
exclude = ["**/*.spec.ts"],
),
module_name = "@angular/material/progress-bar/testing",
deps = [
"//src/cdk/coercion",
"//src/cdk/testing",
],
)

ng_test_library(
name = "harness_tests_lib",
srcs = ["shared.spec.ts"],
deps = [
":testing",
"//src/cdk/testing",
"//src/cdk/testing/testbed",
"//src/material/progress-bar",
"@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/progress-bar",
],
)

ng_web_test_suite(
name = "unit_tests",
deps = [":unit_tests_lib"],
)
9 changes: 9 additions & 0 deletions src/material/progress-bar/testing/index.ts
Original file line number Diff line number Diff line change
@@ -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';
11 changes: 11 additions & 0 deletions src/material/progress-bar/testing/progress-bar-harness-filters.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* @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
*/

import {BaseHarnessFilters} from '@angular/cdk/testing';

export interface ProgressBarHarnessFilters extends BaseHarnessFilters {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {MatProgressBarModule} from '@angular/material/progress-bar';
import {runHarnessTests} from '@angular/material/progress-bar/testing/shared.spec';
import {MatProgressBarHarness} from './progress-bar-harness';

describe('MatProgressBarHarness', () => {
runHarnessTests(MatProgressBarModule, MatProgressBarHarness);
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
* found in the LICENSE file at https://angular.io/license
*/

import {ComponentHarness} from '@angular/cdk/testing';
import {coerceNumberProperty} from '@angular/cdk/coercion';
import {ComponentHarness, HarnessPredicate} from '@angular/cdk/testing';
import {ProgressBarHarnessFilters} from './progress-bar-harness-filters';

/**
* Harness for interacting with a standard mat-progress-bar in tests.
Expand All @@ -16,6 +17,14 @@ import {coerceNumberProperty} from '@angular/cdk/coercion';
export class MatProgressBarHarness extends ComponentHarness {
static hostSelector = 'mat-progress-bar';

/**
* Gets a `HarnessPredicate` that can be used to search for a progress bar with specific
* attributes.
*/
static with(options: ProgressBarHarnessFilters = {}): HarnessPredicate<MatProgressBarHarness> {
return new HarnessPredicate(MatProgressBarHarness, options);
}

/** Gets a promise for the progress bar's value. */
async getValue(): Promise<number|null> {
const host = await this.host();
Expand Down
10 changes: 10 additions & 0 deletions src/material/progress-bar/testing/public-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* @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 './progress-bar-harness';
export * from './progress-bar-harness-filters';
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed';
import {Component} from '@angular/core';
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {MatProgressBarModule} from '@angular/material/progress-bar';

import {MatProgressBarHarness} from './progress-bar-harness';

let fixture: ComponentFixture<ProgressBarHarnessTest>;
let loader: HarnessLoader;
let progressBarHarness: typeof MatProgressBarHarness;
export function runHarnessTests(progressBarModule: typeof MatProgressBarModule,
progressBarHarness: typeof MatProgressBarHarness) {
let fixture: ComponentFixture<ProgressBarHarnessTest>;
let loader: HarnessLoader;

describe('MatProgressBarHarness', () => {
beforeEach(async () => {
await TestBed
.configureTestingModule({
Expand All @@ -22,13 +21,8 @@ describe('MatProgressBarHarness', () => {
fixture = TestBed.createComponent(ProgressBarHarnessTest);
fixture.detectChanges();
loader = TestbedHarnessEnvironment.loader(fixture);
progressBarHarness = MatProgressBarHarness;
});

runTests();
});

function runTests() {
it('should load all progress bar harnesses', async () => {
const progressBars = await loader.getAllHarnesses(progressBarHarness);
expect(progressBars.length).toBe(2);
Expand Down
47 changes: 47 additions & 0 deletions src/material/progress-spinner/testing/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package(default_visibility = ["//visibility:public"])

load("//tools:defaults.bzl", "ng_module", "ng_test_library", "ng_web_test_suite")

ng_module(
name = "testing",
srcs = glob(
["**/*.ts"],
exclude = ["**/*.spec.ts"],
),
module_name = "@angular/material/progress-spinner/testing",
deps = [
"//src/cdk/coercion",
"//src/cdk/testing",
"//src/material/progress-spinner",
],
)

ng_test_library(
name = "harness_tests_lib",
srcs = ["shared.spec.ts"],
deps = [
":testing",
"//src/cdk/testing",
"//src/cdk/testing/testbed",
"//src/material/progress-spinner",
"@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/progress-spinner",
],
)

ng_web_test_suite(
name = "unit_tests",
deps = [":unit_tests_lib"],
)
9 changes: 9 additions & 0 deletions src/material/progress-spinner/testing/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* @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
*/

import {BaseHarnessFilters} from '@angular/cdk/testing';

export interface ProgressSpinnerHarnessFilters extends BaseHarnessFilters {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {MatProgressSpinnerModule} from '@angular/material/progress-spinner';
import {runHarnessTests} from '@angular/material/progress-spinner/testing/shared.spec';
import {MatProgressSpinnerHarness} from './progress-spinner-harness';

describe('Non-MDC-based MatProgressSpinnerHarness', () => {
runHarnessTests(MatProgressSpinnerModule, MatProgressSpinnerHarness);
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
* found in the LICENSE file at https://angular.io/license
*/

import {ComponentHarness} from '@angular/cdk/testing';
import {ProgressSpinnerMode} from '@angular/material/progress-spinner';
import {coerceNumberProperty} from '@angular/cdk/coercion';
import {ComponentHarness, HarnessPredicate} from '@angular/cdk/testing';
import {ProgressSpinnerMode} from '@angular/material/progress-spinner';
import {ProgressSpinnerHarnessFilters} from './progress-spinner-harness-filters';

/**
* Harness for interacting with a standard mat-progress-spinner in tests.
Expand All @@ -17,6 +18,15 @@ import {coerceNumberProperty} from '@angular/cdk/coercion';
export class MatProgressSpinnerHarness extends ComponentHarness {
static hostSelector = 'mat-progress-spinner';

/**
* Gets a `HarnessPredicate` that can be used to search for a progress bar with specific
* attributes.
*/
static with(options: ProgressSpinnerHarnessFilters = {}):
HarnessPredicate<MatProgressSpinnerHarness> {
return new HarnessPredicate(MatProgressSpinnerHarness, options);
}

/** Gets a promise for the progress spinner's value. */
async getValue(): Promise<number|null> {
const host = await this.host();
Expand Down
10 changes: 10 additions & 0 deletions src/material/progress-spinner/testing/public-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* @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 './progress-spinner-harness';
export * from './progress-spinner-harness-filters';
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed';
import {Component} from '@angular/core';
import {ComponentFixture, TestBed} from '@angular/core/testing';
import {MatProgressSpinnerModule, ProgressSpinnerMode} from '@angular/material/progress-spinner';

import {MatProgressSpinnerHarness} from './progress-spinner-harness';

let fixture: ComponentFixture<ProgressSpinnerHarnessTest>;
let loader: HarnessLoader;
let progressSpinnerHarness: typeof MatProgressSpinnerHarness;
export function runHarnessTests(progressSpinnerModule: typeof MatProgressSpinnerModule,
progressSpinnerHarness: typeof MatProgressSpinnerHarness) {
let fixture: ComponentFixture<ProgressSpinnerHarnessTest>;
let loader: HarnessLoader;

describe('MatProgressSpinnerHarness', () => {
beforeEach(async () => {
await TestBed
.configureTestingModule({
Expand All @@ -22,13 +21,8 @@ describe('MatProgressSpinnerHarness', () => {
fixture = TestBed.createComponent(ProgressSpinnerHarnessTest);
fixture.detectChanges();
loader = TestbedHarnessEnvironment.loader(fixture);
progressSpinnerHarness = MatProgressSpinnerHarness;
});

runTests();
});

function runTests() {
it('should load all progress spinner harnesses', async () => {
const progressSpinners = await loader.getAllHarnesses(progressSpinnerHarness);
expect(progressSpinners.length).toBe(2);
Expand Down
4 changes: 4 additions & 0 deletions test/karma-system-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ System.config({
'@angular/material/menu/testing/shared.spec': 'dist/packages/material/menu/testing/shared.spec.js',
'@angular/material/paginator': 'dist/packages/material/paginator/index.js',
'@angular/material/progress-bar': 'dist/packages/material/progress-bar/index.js',
'@angular/material/progress-bar/testing': 'dist/packages/material/progress-bar/testing/index.js',
'@angular/material/progress-bar/testing/shared.spec': 'dist/packages/material/progress-bar/testing/shared.spec.js',
'@angular/material/progress-spinner': 'dist/packages/material/progress-spinner/index.js',
'@angular/material/progress-spinner/testing': 'dist/packages/material/progress-spinner/testing/index.js',
'@angular/material/progress-spinner/testing/shared.spec': 'dist/packages/material/progress-spinner/testing/shared.spec.js',
'@angular/material/radio': 'dist/packages/material/radio/index.js',
'@angular/material/select': 'dist/packages/material/select/index.js',
'@angular/material/sidenav': 'dist/packages/material/sidenav/index.js',
Expand Down

0 comments on commit 26df035

Please sign in to comment.