Skip to content

Commit 9b0448d

Browse files
committed
test: read default color from theme palette
1 parent 68da473 commit 9b0448d

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

src/modules/service-catalog/components/service-catalog-list/ServiceCatalogListItem.spec.tsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,10 @@ describe("ServiceCatalogListItem", () => {
7474
/>
7575
);
7676

77-
const itemTitle = screen.getByTestId("service-catalog-list-item");
78-
expect(itemTitle).toHaveStyle(`color: ${theme.colors.foreground}`);
77+
const itemContainer = screen.getByTestId(
78+
"service-catalog-list-item-container"
79+
);
80+
expect(itemContainer).toHaveStyle(`color: ${theme.colors.foreground}`);
7981
});
8082

8183
it("should use primaryHue as card border color on hover", async () => {
@@ -87,14 +89,19 @@ describe("ServiceCatalogListItem", () => {
8789
);
8890

8991
const user = userEvent.setup();
90-
const itemTitle = screen.getByTestId("service-catalog-list-item");
91-
const defaultBorderColor = "#d8dcde";
92+
const itemContainer = screen.getByTestId(
93+
"service-catalog-list-item-container"
94+
);
95+
const defaultBorderColor = DEFAULT_THEME.palette.grey?.[300];
9296

93-
expect(itemTitle).toHaveStyle(`border-color: ${defaultBorderColor}`);
97+
expect(defaultBorderColor).toBeTruthy();
98+
expect(itemContainer).toHaveStyle(`border-color: ${defaultBorderColor}`);
9499

95-
await user.hover(itemTitle);
100+
await user.hover(itemContainer);
96101

97-
expect(itemTitle).toHaveStyle(`border-color: ${theme.colors.primaryHue}`);
102+
expect(itemContainer).toHaveStyle(
103+
`border-color: ${theme.colors.primaryHue}`
104+
);
98105
});
99106
});
100107
});

src/modules/service-catalog/components/service-catalog-list/ServiceCatalogListItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const ServiceCatalogListItem = ({
6969
}) => {
7070
return (
7171
<ItemContainer
72-
data-testid="service-catalog-list-item"
72+
data-testid="service-catalog-list-item-container"
7373
href={`${helpCenterPath}/services/${serviceItem.id}`}
7474
>
7575
<IconContainer>

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10836,7 +10836,7 @@ nth-check@^2.0.1:
1083610836
dependencies:
1083710837
boolbase "^1.0.0"
1083810838

10839-
[email protected].20, nwsapi@^2.2.2:
10839+
nwsapi@^2.2.2, nwsapi@^2.2.20:
1084010840
version "2.2.20"
1084110841
resolved "https://registry.yarnpkg.com/nwsapi/-/nwsapi-2.2.20.tgz#22e53253c61e7b0e7e93cef42c891154bcca11ef"
1084210842
integrity sha512-/ieB+mDe4MrrKMT8z+mQL8klXydZWGR5Dowt4RAGKbJ3kIGEx3X4ljUo+6V73IXtUPWgfOlU5B9MlGxFO5T+cA==

0 commit comments

Comments
 (0)