@coveord/plasma-react-icons 56.16.0 → 56.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.tsbuildinfo +1 -1
- package/dist/cjs/generated/index.d.ts +497 -497
- package/dist/cjs/generated/index.d.ts.map +1 -1
- package/dist/cjs/generated/index.js +1581 -1581
- package/dist/cjs/generated/index.js.map +1 -1
- package/dist/cjs/testing-library/README.md +21 -5
- package/dist/esm/generated/index.d.ts +497 -497
- package/dist/esm/generated/index.d.ts.map +1 -1
- package/dist/esm/generated/index.js +497 -497
- package/dist/esm/generated/index.js.map +1 -1
- package/dist/esm/testing-library/README.md +21 -5
- package/package.json +1 -1
|
@@ -19,20 +19,36 @@ import {getByIconName, queryByIconName, findByIconName} from '@coveord/plasma-re
|
|
|
19
19
|
Add this to a separate test utilities file (e.g., `test-utils.ts` or `testing-utils.ts`):
|
|
20
20
|
|
|
21
21
|
```typescript
|
|
22
|
-
|
|
22
|
+
// test-utils.ts
|
|
23
|
+
|
|
23
24
|
import {extendScreen, IconQueries} from '@coveord/plasma-react-icons/testing-library';
|
|
25
|
+
import {screen as defaultScreen, within as defaultWithin} from '@testing-library/react';
|
|
24
26
|
|
|
25
27
|
// Extend screen with icon queries with its type so that you have autocomplete in your IDE
|
|
26
28
|
const screen: typeof defaultScreen & IconQueries = extendScreen(defaultScreen);
|
|
27
29
|
|
|
28
|
-
//
|
|
30
|
+
// Extend within with icon queries with its type so that you have autocomplete in your IDE
|
|
31
|
+
const within = (element: HTMLElement) => extendScreen(defaultWithin(element));
|
|
32
|
+
|
|
33
|
+
// Export everything from testing library + our enhanced screen & within
|
|
29
34
|
export * from '@testing-library/react';
|
|
30
|
-
export {screen};
|
|
35
|
+
export {screen, within};
|
|
36
|
+
```
|
|
31
37
|
|
|
32
|
-
|
|
38
|
+
```typescript
|
|
39
|
+
// in your test file
|
|
33
40
|
import {render, screen} from './test-utils'; // or your utilities file path
|
|
34
41
|
|
|
35
|
-
|
|
42
|
+
test('finds icon by name', () => {
|
|
43
|
+
render(<YourComponent />);
|
|
44
|
+
|
|
45
|
+
// You can use the getByIconName method directly on the screen object
|
|
46
|
+
expect(screen.getByIconName('iconEdit')).toBeVisible();
|
|
47
|
+
|
|
48
|
+
// You can use the getByIconName method directly on the object returned by the within method
|
|
49
|
+
const editButton = screen.getByRole('button', {name: /edit/i});
|
|
50
|
+
expect(within(editButton).getByIconName('iconEdit')).toBeVisible();
|
|
51
|
+
});
|
|
36
52
|
```
|
|
37
53
|
|
|
38
54
|
### Option 2: Import Individual Queries
|