-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(material-experimental/mdc-tooltip): add test harness (#21855)
Sets up a test harness for the MDC-based tooltip.
- Loading branch information
Showing
9 changed files
with
128 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
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-experimental/mdc-tooltip/testing", | ||
deps = [ | ||
"//src/cdk/testing", | ||
"//src/material/tooltip/testing", | ||
], | ||
) | ||
|
||
filegroup( | ||
name = "source-files", | ||
srcs = glob(["**/*.ts"]), | ||
) | ||
|
||
ng_test_library( | ||
name = "unit_tests_lib", | ||
srcs = glob(["**/*.spec.ts"]), | ||
deps = [ | ||
":testing", | ||
"//src/material-experimental/mdc-tooltip", | ||
"//src/material/tooltip/testing:harness_tests_lib", | ||
], | ||
) | ||
|
||
ng_web_test_suite( | ||
name = "unit_tests", | ||
static_files = ["@npm//:node_modules/@material/tooltip/dist/mdc.tooltip.js"], | ||
deps = [ | ||
":unit_tests_lib", | ||
"//src/material-experimental:mdc_require_config.js", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
10 changes: 10 additions & 0 deletions
10
src/material-experimental/mdc-tooltip/testing/public-api.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 './tooltip-harness'; | ||
export {TooltipHarnessFilters} from '@angular/material/tooltip/testing'; |
7 changes: 7 additions & 0 deletions
7
src/material-experimental/mdc-tooltip/testing/tooltip-harness.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import {MatTooltipModule} from '@angular/material-experimental/mdc-tooltip'; | ||
import {runHarnessTests} from '@angular/material/tooltip/testing/shared.spec'; | ||
import {MatTooltipHarness} from './index'; | ||
|
||
describe('MDC-based MatTooltipHarness', () => { | ||
runHarnessTests(MatTooltipModule, MatTooltipHarness as any); | ||
}); |
27 changes: 27 additions & 0 deletions
27
src/material-experimental/mdc-tooltip/testing/tooltip-harness.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* @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 {HarnessPredicate} from '@angular/cdk/testing'; | ||
import {_MatTooltipHarnessBase, TooltipHarnessFilters} from '@angular/material/tooltip/testing'; | ||
|
||
/** Harness for interacting with a standard mat-tooltip in tests. */ | ||
export class MatTooltipHarness extends _MatTooltipHarnessBase { | ||
protected _optionalPanel = | ||
this.documentRootLocatorFactory().locatorForOptional('.mat-mdc-tooltip'); | ||
static hostSelector = '.mat-mdc-tooltip-trigger'; | ||
|
||
/** | ||
* Gets a `HarnessPredicate` that can be used to search | ||
* for a tooltip trigger with specific attributes. | ||
* @param options Options for narrowing the search. | ||
* @return a `HarnessPredicate` configured with the given options. | ||
*/ | ||
static with(options: TooltipHarnessFilters = {}): HarnessPredicate<MatTooltipHarness> { | ||
return new HarnessPredicate(MatTooltipHarness, options); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters