Skip to content

Commit

Permalink
test(material-experimental/chips) Port unit tests for mdc chips
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vanessanschmitt committed Jul 10, 2019
1 parent fe26614 commit 7d91ffe
Show file tree
Hide file tree
Showing 20 changed files with 3,386 additions and 142 deletions.
45 changes: 28 additions & 17 deletions src/material-experimental/mdc-chips/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package(default_visibility = ["//visibility:public"])

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

ng_module(
name = "mdc-chips",
Expand All @@ -14,6 +14,7 @@ ng_module(
deps = [
"//src/material/core",
"//src/material/form-field",
"@npm//@angular/animations",
"@npm//@angular/common",
"@npm//@angular/core",
"@npm//@angular/forms",
Expand Down Expand Up @@ -44,26 +45,36 @@ sass_binary(
],
)

ng_e2e_test_library(
name = "e2e_test_sources",
srcs = glob(["**/*.e2e.spec.ts"]),
ng_test_library(
name = "chips_tests_lib",
srcs = glob(
["**/*.spec.ts"],
exclude = ["**/*.e2e.spec.ts"],
),
deps = [
"//src/cdk/testing/e2e",
":mdc-chips",
"//src/cdk/a11y",
"//src/cdk/bidi",
"//src/cdk/keycodes",
"//src/cdk/platform",
"//src/cdk/testing",
"//src/material/core",
"//src/material/form-field",
"//src/material/input",
"@npm//@angular/animations",
"@npm//@angular/common",
"@npm//@angular/forms",
"@npm//@angular/platform-browser",
"@npm//material-components-web",
"@npm//rxjs",
],
)

protractor_web_test_suite(
name = "e2e_tests",
configuration = "//src/e2e-app:protractor.conf.js",
data = [
"//tools/axe-protractor",
"@npm//@angular/bazel",
],
on_prepare = "//src/e2e-app:start-devserver.js",
server = "//src/e2e-app:devserver",
tags = ["e2e"],
ng_web_test_suite(
name = "unit_tests",
static_files = ["@npm//node_modules/@material/chips:dist/mdc.chips.js"],
deps = [
":e2e_test_sources",
"//src/cdk/testing/e2e",
":chips_tests_lib",
"//src/material-experimental:mdc_require_config.js",
],
)
Loading

0 comments on commit 7d91ffe

Please sign in to comment.