@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.
@@ -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
- import {screen as defaultScreen} from '@testing-library/react';
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
- // Export everything from testing library + our enhanced screen
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
- // Then, in your test file
38
+ ```typescript
39
+ // in your test file
33
40
  import {render, screen} from './test-utils'; // or your utilities file path
34
41
 
35
- // Now screen.getByIconName, screen.queryByIconName, etc. are available
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