Skip to content

Commit d865572

Browse files
test(material-experimental/chips) Port unit tests for mdc chips
Copied chip-remove.spec. Copied chip-input.spec and changed its test component template to use grid/row. Copied chip-list.spec basic tests to chip-set.spec. Copied chip-list.spec to chip-listbox.spec and removed form-field integration, mat-chip-remove integration, and related keyboard shortcuts. Copied chip-list.spec to chip-grid.spec and removed the selection behavior. Updated keyboard tests to reflect that it is using GridFocusKeyManager, which has both an active row and an active column. Updated some of the form tests where the value was being changed via selection to change the value in a different way, like by adding a chip. Copied chip.spec basic tests to chip.spec. Copied chip.spec to chip-option.spec and removed logic related to user removal of the chip. Copied chip.spec to chip-row.spec and removed selection logic. Updated component code to fix bugs/missing features that were caught by the unit tests: - Added missing ControlValueAccessor method setDisabledState to mat-chip-listbox and mat-chip-grid - Added user-defined tab index to mat-chip-listbox and mat-chip-grid. - Removed role from empty mat-chip-listbox and mat-chip-grid. - Moved the logic in mat-chip-set that updates the lastDestroyedChipIndex from the removed subscription to a new destroyed subscription. - Replaced _optionChip and _rowChips ViewChildren in mat-chip-listbox and mat-chip-grid with just overriding _chips, to fix bugs where the _chips.changes subscription was trying to do things with _optionChips/_rowChips but those QueryLists were still out of date. - Added placeholder setter to mat-chip-grid. - Added value setter to mat-chip-listbox. - Added injected animationMode to mat-chip and its subcomponents. - Updated rippleConfig to be injected into mat-chip and its subcomponents. - Added mat-chip-remove class to remove icon.
1 parent 5b3e846 commit d865572

19 files changed

+3388
-134
lines changed

src/material-experimental/mdc-chips/BUILD.bazel

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package(default_visibility = ["//visibility:public"])
22

33
load("@io_bazel_rules_sass//:defs.bzl", "sass_binary", "sass_library")
4-
load("//tools:defaults.bzl", "ng_e2e_test_library", "ng_module", "protractor_web_test_suite")
4+
load("//tools:defaults.bzl", "ng_module", "ng_test_library", "ng_web_test_suite")
55

66
ng_module(
77
name = "mdc-chips",
@@ -14,6 +14,7 @@ ng_module(
1414
deps = [
1515
"//src/material/core",
1616
"//src/material/form-field",
17+
"@npm//@angular/animations",
1718
"@npm//@angular/common",
1819
"@npm//@angular/core",
1920
"@npm//@angular/forms",
@@ -44,26 +45,36 @@ sass_binary(
4445
],
4546
)
4647

47-
ng_e2e_test_library(
48-
name = "e2e_test_sources",
49-
srcs = glob(["**/*.e2e.spec.ts"]),
48+
ng_test_library(
49+
name = "chips_tests_lib",
50+
srcs = glob(
51+
["**/*.spec.ts"],
52+
exclude = ["**/*.e2e.spec.ts"],
53+
),
5054
deps = [
51-
"//src/cdk/testing/e2e",
55+
":mdc-chips",
56+
"//src/cdk/a11y",
57+
"//src/cdk/bidi",
58+
"//src/cdk/keycodes",
59+
"//src/cdk/platform",
60+
"//src/cdk/testing",
61+
"//src/material/core",
62+
"//src/material/form-field",
63+
"//src/material/input",
64+
"@npm//@angular/animations",
65+
"@npm//@angular/common",
66+
"@npm//@angular/forms",
67+
"@npm//@angular/platform-browser",
68+
"@npm//material-components-web",
69+
"@npm//rxjs",
5270
],
5371
)
5472

55-
protractor_web_test_suite(
56-
name = "e2e_tests",
57-
configuration = "//src/e2e-app:protractor.conf.js",
58-
data = [
59-
"//tools/axe-protractor",
60-
"@npm//@angular/bazel",
61-
],
62-
on_prepare = "//src/e2e-app:start-devserver.js",
63-
server = "//src/e2e-app:devserver",
64-
tags = ["e2e"],
73+
ng_web_test_suite(
74+
name = "unit_tests",
75+
static_files = ["@npm//node_modules/@material/chips:dist/mdc.chips.js"],
6576
deps = [
66-
":e2e_test_sources",
67-
"//src/cdk/testing/e2e",
77+
":chips_tests_lib",
78+
"//src/material-experimental:mdc_require_config.js",
6879
],
6980
)

0 commit comments

Comments
 (0)