Skip to content

Commit dcde115

Browse files
vanessanschmittjelbourn
authored andcommitted
test(material-experimental/chips) Port unit tests for mdc chips (#16447)
Ported existing unit tests as follows: - 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. Also 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 - Stopped overwriting user-defined tab index to mat-chip-listbox and mat-chip-grid. - Removed role from empty mat-chip-listbox and mat-chip-grid. - Added a new subscription in mat-chip-set to chip destroyed events, and moved the logic that updates the lastDestroyedChipIndex out of the removed subscription into the 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. - Switched click handler to mousedown handler in mat-chip-row. - Added mat-chip-remove class to remove icon.
1 parent bb7af77 commit dcde115

20 files changed

+3386
-135
lines changed

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

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +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")
5-
load("//src/e2e-app:test_suite.bzl", "e2e_test_suite")
4+
load("//tools:defaults.bzl", "ng_module", "ng_test_library", "ng_web_test_suite")
65

76
ng_module(
87
name = "mdc-chips",
@@ -15,6 +14,7 @@ ng_module(
1514
deps = [
1615
"//src/material/core",
1716
"//src/material/form-field",
17+
"@npm//@angular/animations",
1818
"@npm//@angular/common",
1919
"@npm//@angular/core",
2020
"@npm//@angular/forms",
@@ -45,18 +45,36 @@ sass_binary(
4545
],
4646
)
4747

48-
ng_e2e_test_library(
49-
name = "e2e_test_sources",
50-
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+
),
5154
deps = [
52-
"//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",
5370
],
5471
)
5572

56-
e2e_test_suite(
57-
name = "e2e_tests",
73+
ng_web_test_suite(
74+
name = "unit_tests",
75+
static_files = ["@npm//:node_modules/@material/chips/dist/mdc.chips.js"],
5876
deps = [
59-
":e2e_test_sources",
60-
"//src/cdk/testing/e2e",
77+
":chips_tests_lib",
78+
"//src/material-experimental:mdc_require_config.js",
6179
],
6280
)

0 commit comments

Comments
 (0)