Skip to content

Commit 1ade334

Browse files
committed
fix(material/card): remove card deps on legacy-card
1 parent c753209 commit 1ade334

File tree

5 files changed

+26
-32
lines changed

5 files changed

+26
-32
lines changed

src/material/card/testing/BUILD.bazel

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ ng_test_library(
2525
["**/*.spec.ts"],
2626
exclude = [
2727
"**/*.e2e.spec.ts",
28+
"shared.spec.ts",
2829
],
2930
),
3031
deps = [
32+
":harness_tests_lib",
3133
":testing",
3234
"//src/material/card",
33-
"//src/material/legacy-card/testing:harness_tests_lib",
3435
],
3536
)
3637

@@ -57,3 +58,15 @@ e2e_test_suite(
5758
"//src/cdk/testing/private/e2e",
5859
],
5960
)
61+
62+
ng_test_library(
63+
name = "harness_tests_lib",
64+
srcs = ["shared.spec.ts"],
65+
deps = [
66+
":testing",
67+
"//src/cdk/testing",
68+
"//src/cdk/testing/testbed",
69+
"//src/material/card",
70+
"@npm//@angular/platform-browser",
71+
],
72+
)

src/material/card/testing/card-harness.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {MatCardModule} from '@angular/material/card';
2-
import {runHarnessTests} from '@angular/material/legacy-card/testing/shared.spec';
2+
import {runHarnessTests} from './shared.spec';
33
import {MatCardHarness, MatCardSection} from './card-harness';
44

55
describe('MDC-based MatCardHarness', () => {

src/material/legacy-card/testing/shared.spec.ts renamed to src/material/card/testing/shared.spec.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@ import {ComponentHarness, HarnessLoader, parallel} from '@angular/cdk/testing';
22
import {TestbedHarnessEnvironment} from '@angular/cdk/testing/testbed';
33
import {Component} from '@angular/core';
44
import {ComponentFixture, TestBed} from '@angular/core/testing';
5-
import {MatLegacyCardModule} from '@angular/material/legacy-card';
6-
import {
7-
MatLegacyCardHarness,
8-
MatLegacyCardSection,
9-
} from '@angular/material/legacy-card/testing/card-harness';
5+
import {MatCardModule} from '@angular/material/card';
6+
import {MatCardHarness, MatCardSection} from '@angular/material/card/testing';
107

118
/** Shared tests to run on both the original and MDC-based cards. */
129
export function runHarnessTests(
13-
cardModule: typeof MatLegacyCardModule,
14-
cardHarness: typeof MatLegacyCardHarness,
10+
cardModule: typeof MatCardModule,
11+
cardHarness: typeof MatCardHarness,
1512
contentSelectors: {header: string; content: string; actions: string; footer: string},
1613
) {
1714
let fixture: ComponentFixture<CardHarnessTest>;
@@ -73,32 +70,28 @@ export function runHarnessTests(
7370

7471
it('should get a harness loader for the card header', async () => {
7572
const card = await loader.getHarness(cardHarness.with({title: 'Shiba Inu'}));
76-
const headerLoader = await card.getChildLoader(contentSelectors.header as MatLegacyCardSection);
73+
const headerLoader = await card.getChildLoader(contentSelectors.header as MatCardSection);
7774
const headerSubcomponents = (await headerLoader?.getAllHarnesses(DummyHarness)) ?? [];
7875
expect(headerSubcomponents.length).toBe(2);
7976
});
8077

8178
it('should get a harness loader for the card content', async () => {
8279
const card = await loader.getHarness(cardHarness.with({title: 'Shiba Inu'}));
83-
const contentLoader = await card.getChildLoader(
84-
contentSelectors.content as MatLegacyCardSection,
85-
);
80+
const contentLoader = await card.getChildLoader(contentSelectors.content as MatCardSection);
8681
const contentSubcomponents = (await contentLoader?.getAllHarnesses(DummyHarness)) ?? [];
8782
expect(contentSubcomponents.length).toBe(1);
8883
});
8984

9085
it('should get a harness loader for the card actions', async () => {
9186
const card = await loader.getHarness(cardHarness.with({title: 'Shiba Inu'}));
92-
const actionLoader = await card.getChildLoader(
93-
contentSelectors.actions as MatLegacyCardSection,
94-
);
87+
const actionLoader = await card.getChildLoader(contentSelectors.actions as MatCardSection);
9588
const actionSubcomponents = (await actionLoader?.getAllHarnesses(DummyHarness)) ?? [];
9689
expect(actionSubcomponents.length).toBe(2);
9790
});
9891

9992
it('should get a harness loader for the card footer', async () => {
10093
const card = await loader.getHarness(cardHarness.with({title: 'Shiba Inu'}));
101-
const footerLoader = await card.getChildLoader(contentSelectors.footer as MatLegacyCardSection);
94+
const footerLoader = await card.getChildLoader(contentSelectors.footer as MatCardSection);
10295
const footerSubcomponents = (await footerLoader?.getAllHarnesses(DummyHarness)) ?? [];
10396
expect(footerSubcomponents.length).toBe(1);
10497
});

src/material/legacy-card/testing/BUILD.bazel

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,6 @@ filegroup(
1818
srcs = glob(["**/*.ts"]),
1919
)
2020

21-
ng_test_library(
22-
name = "harness_tests_lib",
23-
srcs = ["shared.spec.ts"],
24-
deps = [
25-
":testing",
26-
"//src/cdk/testing",
27-
"//src/cdk/testing/testbed",
28-
"//src/material/legacy-card",
29-
"@npm//@angular/platform-browser",
30-
],
31-
)
32-
3321
ng_test_library(
3422
name = "unit_tests_lib",
3523
srcs = glob(
@@ -39,8 +27,8 @@ ng_test_library(
3927
],
4028
),
4129
deps = [
42-
":harness_tests_lib",
4330
":testing",
31+
"//src/material/card/testing:harness_tests_lib",
4432
"//src/material/legacy-card",
4533
],
4634
)

src/material/legacy-card/testing/card-harness.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import {MatLegacyCardModule} from '@angular/material/legacy-card';
2-
import {runHarnessTests} from '@angular/material/legacy-card/testing/shared.spec';
2+
import {runHarnessTests} from '@angular/material/card/testing/shared.spec';
33
import {MatLegacyCardHarness, MatLegacyCardSection} from './card-harness';
44

55
describe('Non-MDC-based MatCardHarness', () => {
6-
runHarnessTests(MatLegacyCardModule, MatLegacyCardHarness, {
6+
runHarnessTests(MatLegacyCardModule, MatLegacyCardHarness as any, {
77
header: MatLegacyCardSection.HEADER,
88
content: MatLegacyCardSection.CONTENT,
99
actions: MatLegacyCardSection.ACTIONS,

0 commit comments

Comments
 (0)