-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.Added a regex filter for the AIX OS. 2. Added constants for the STORYBOOK_MODE 3.Removed unecessary closing of with or '||' operator #6635
Changes from all commits
22ec8ce
5dfa804
9e24d8a
e23e272
5bbae24
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,37 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
|
||
import { STORYBOOK_MODE_THEME } from '@/.storybook/constants'; | ||
|
||
import ThemeToggle from '../'; | ||
|
||
let mockCurrentTheme = 'light'; | ||
let mockCurrentTheme = STORYBOOK_MODE_THEME.light; | ||
|
||
const toggleTheme = () => { | ||
mockCurrentTheme = mockCurrentTheme === 'light' ? 'dark' : 'light'; | ||
mockCurrentTheme = | ||
mockCurrentTheme === STORYBOOK_MODE_THEME.light | ||
? STORYBOOK_MODE_THEME.dark | ||
: STORYBOOK_MODE_THEME.light; | ||
}; | ||
|
||
describe('ThemeToggle', () => { | ||
let toggle; | ||
|
||
beforeEach(() => { | ||
mockCurrentTheme = 'light'; | ||
mockCurrentTheme = STORYBOOK_MODE_THEME.light; | ||
|
||
render(<ThemeToggle onClick={toggleTheme} />); | ||
toggle = screen.getByRole('button'); | ||
}); | ||
|
||
it('switches dark theme to light theme', async () => { | ||
mockCurrentTheme = 'dark'; | ||
mockCurrentTheme = STORYBOOK_MODE_THEME.dark; | ||
await userEvent.click(toggle); | ||
expect(mockCurrentTheme).toBe('light'); | ||
expect(mockCurrentTheme).toBe(STORYBOOK_MODE_THEME.light); | ||
}); | ||
|
||
it('switches light theme to dark theme', async () => { | ||
await userEvent.click(toggle); | ||
expect(mockCurrentTheme).toBe('dark'); | ||
expect(mockCurrentTheme).toBe(STORYBOOK_MODE_THEME.dark); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,13 +25,13 @@ const WithSidebarCrossLinks: FC<WithCrossLinksProps> = ({ navKey }) => { | |
|
||
return ( | ||
<div className="mt-4 grid w-full grid-cols-2 gap-4 xs:grid-cols-1"> | ||
{(previousCrossLink && ( | ||
{previousCrossLink && ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Afaik the |
||
<CrossLink | ||
type="previous" | ||
text={previousCrossLink.label} | ||
link={previousCrossLink.link} | ||
/> | ||
)) || <div />} | ||
)} | ||
|
||
{nextCrossLink && ( | ||
<CrossLink | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import type { UserOS } from '@/types/userOS'; | ||
|
||
export const detectOsInUserAgent = (userAgent: string | undefined): UserOS => { | ||
const osMatch = userAgent?.match(/(Win|Mac|Linux)/); | ||
const osMatch = userAgent?.match(/(Win|Mac|Linux|AIX)/); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think as mentioned before, instead of adding |
||
switch (osMatch && osMatch[1]) { | ||
case 'Win': | ||
return 'WIN'; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As mentioned before, we shouldn't have Sotrybook constants being imported in Application code, you can create a new constant similar to the Storybook one, on an App constants file, like
next.constants.mjs