Skip to content

Commit e4726af

Browse files
committed
Update Button and IconUtils tests per PR feedback
1 parent c85f1e6 commit e4726af

2 files changed

Lines changed: 33 additions & 35 deletions

File tree

src/atoms/buttons/button.test.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ describe("Button", () => {
1414
const { getByText } = render(<Button>{expected}</Button>);
1515

1616
// Assert
17-
await wait(() => {
18-
expect(getByText(expected)).not.toBeNull();
19-
});
17+
expect(getByText(expected)).not.toBeNull();
2018
});
2119

2220
it("when accessibleText provided, renders child accessible span", () => {

src/utilities/icon-utils.test.ts

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,43 @@ describe("IconUtils", () => {
2424
IconUtils.clearRegistry();
2525

2626
// Assert
27-
expect(Object.keys(IconUtils.getRegistry)).toHaveLength(0);
27+
expect(IconUtils.getRegistry()).toEqual({});
2828
});
2929
});
3030

3131
// #endregion clearRegistry
3232

33+
// -----------------------------------------------------------------------------------------
34+
// #region getRegistry
35+
// -----------------------------------------------------------------------------------------
36+
37+
describe("getRegistry", () => {
38+
test("given no icons registered, returns empty object", () => {
39+
// Arrange & Act
40+
const result = IconUtils.getRegistry();
41+
42+
// Assert
43+
expect(result).toEqual({});
44+
});
45+
46+
test("given icons registered, returns new instance of registry", () => {
47+
// Arrange
48+
const ChevronDown = getSvgIconByType(Icons.ChevronDown);
49+
IconUtils.registerSvgIcon(ChevronDown);
50+
51+
// Act
52+
const firstResult = IconUtils.getRegistry();
53+
const secondResult = IconUtils.getRegistry();
54+
55+
// Assert
56+
expect(firstResult[ChevronDown.type]).not.toBeUndefined();
57+
expect(secondResult[ChevronDown.type]).not.toBeUndefined();
58+
expect(firstResult).not.toBe(secondResult);
59+
});
60+
});
61+
62+
// #endregion getRegistry
63+
3364
// -----------------------------------------------------------------------------------------
3465
// #region getSvg
3566
// -----------------------------------------------------------------------------------------
@@ -113,37 +144,6 @@ describe("IconUtils", () => {
113144

114145
// #endregion getSvgIcon
115146

116-
// -----------------------------------------------------------------------------------------
117-
// #region getRegistry
118-
// -----------------------------------------------------------------------------------------
119-
120-
describe("getRegistry", () => {
121-
test("given no icons registered, returns empty object", () => {
122-
// Arrange & Act
123-
const result = IconUtils.getRegistry();
124-
125-
// Assert
126-
expect(Object.keys(result)).toHaveLength(0);
127-
});
128-
129-
test("given icons registered, returns new instance of registry", () => {
130-
// Arrange
131-
const ChevronDown = getSvgIconByType(Icons.ChevronDown);
132-
IconUtils.registerSvgIcon(ChevronDown);
133-
134-
// Act
135-
const firstResult = IconUtils.getRegistry();
136-
const secondResult = IconUtils.getRegistry();
137-
138-
// Assert
139-
expect(firstResult[ChevronDown.type]).not.toBeUndefined();
140-
expect(secondResult[ChevronDown.type]).not.toBeUndefined();
141-
expect(firstResult).not.toBe(secondResult);
142-
});
143-
});
144-
145-
// #endregion getRegistry
146-
147147
// -----------------------------------------------------------------------------------------
148148
// #region register
149149
// -----------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)