Skip to content

Commit

Permalink
update readme, lint
Browse files Browse the repository at this point in the history
  • Loading branch information
shaneeza committed Feb 14, 2025
1 parent 6bd672c commit 36c3c5a
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .changeset/chatty-ears-exercise.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ e.g.
### Test Harnesses
Exports `getTestUtils`, a util to reliably interact with LG `Code` in a product test suite. For more details, check out the [README](https://github.com/mongodb/leafygreen-ui/tree/main/packages/code#test-harnesses) [LG-4799](https://jira.mongodb.org/browse/LG-4799)

Also exports the constant, `LGIDs` which stores `data-lgid` values.
Exports `getLgIds`, a util to instantiate an object of `data-lgid` values for a given LG `Code` component instance.


## What's changed?
Expand Down
2 changes: 1 addition & 1 deletion packages/code/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ interface LanguageOption {
```tsx
import { getTestUtils } from '@leafygreen-ui/code';

const utils = getTestUtils(lgId?: string); // lgId refers to the custom `data-lgid` attribute passed to `Code`. It defaults to 'lg-code' if left empty.
const utils = getTestUtils(lgId?: `lg-${string}`); // lgId refers to the custom `data-lgid` attribute passed to `Code`. It defaults to 'lg-code' if left empty.
```

#### Single `Code` component
Expand Down
2 changes: 1 addition & 1 deletion packages/code/src/Code/Code.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import CopyButton from '../CopyButton/CopyButton';
import { Panel } from '../Panel';
import { Syntax } from '../Syntax';
import { Language } from '../types';
import { DEFAULT_LGID_ROOT, getLgIds } from '../utils/getLgIds';

import {
getCodeStyles,
Expand All @@ -30,7 +31,6 @@ import {
DetailedElementProps,
ScrollState,
} from './Code.types';
import { DEFAULT_LGID_ROOT, getLgIds } from '../utils/getLgIds';

//TODO: move to utils
export function hasMultipleLines(string: string): boolean {
Expand Down
2 changes: 1 addition & 1 deletion packages/code/src/CodeContext/CodeContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const CodeContextProvider = ({
isLoading,
lgids,
};
}, [contents, language, showPanel, isLoading]);
}, [contents, language, showPanel, isLoading, lgids]);

return (
<LeafyGreenProvider darkMode={darkMode}>
Expand Down
2 changes: 1 addition & 1 deletion packages/code/src/CopyButton/CopyButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import Tooltip, {
} from '@leafygreen-ui/tooltip';

import { useCodeContext } from '../CodeContext/CodeContext';
// import { LGIDs } from '../constants';

// import { LGIDs } from '../constants';
import { COPIED_SUCCESS_DURATION, COPIED_TEXT, COPY_TEXT } from './constants';
import { getCopyButtonStyles } from './CopyButton.styles';
import { CopyProps } from './CopyButton.types';
Expand Down
3 changes: 2 additions & 1 deletion packages/code/src/utils/getTestUtils/getTestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { getByLgId, queryBySelector } from '@lg-tools/test-harnesses';
import { getTestUtils as getButtonTestUtils } from '@leafygreen-ui/button';
import { getTestUtils as getSelectTestUtils } from '@leafygreen-ui/select';

import { TestUtilsReturnType } from './getTestUtils.types';
import { DEFAULT_LGID_ROOT, getLgIds } from '../getLgIds';

import { TestUtilsReturnType } from './getTestUtils.types';

export const getTestUtils = (
lgId: `lg-${string}` = DEFAULT_LGID_ROOT,
): TestUtilsReturnType => {
Expand Down

0 comments on commit 36c3c5a

Please sign in to comment.