Skip to content

Commit 6840ddd

Browse files
test(app): add coverage for recent searches UI interactions (JhaSourav07#751)
* year selection * recent searches
1 parent e8de0b1 commit 6840ddd

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

app/customize/components/ThemeSelector.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function StyledSelect({
2020
id={id}
2121
value={value}
2222
onChange={(e) => onChange(e.target.value)}
23-
className="w-full bg-gray-100/80 backdrop-blur-md border border-black/10 dark:bg-white/[0.03] dark:border-white/10 rounded-xl px-4 py-2.5 text-sm text-black dark:text-white outline-none focus:border-emerald-500/50 transition-colors appearance-none cursor-pointer"
23+
className="w-full bg-gray-100/80 backdrop-blur-md border border-black/10 dark:bg-white/[0.03] dark:border-white/10 rounded-xl px-4 py-2.5 text-sm text-black dark:text-white outline-none focus:border-emerald-500/50 transition-colors appearance-none cursor-pointer [color-scheme:light] dark:[color-scheme:dark] [&>option]:bg-white [&>option]:text-black dark:[&>option]:bg-[#0a0a0a] dark:[&>option]:text-white"
2424
>
2525
{children}
2626
</select>

app/page.test.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ vi.mock('framer-motion', () => ({
5252

5353
vi.mock('@/hooks/useRecentSearches', () => ({
5454
useRecentSearches: () => ({
55-
searches: [],
55+
searches: ['octocat', 'torvalds'],
5656
addSearch: vi.fn(),
5757
clearSearches: vi.fn(),
5858
}),
@@ -100,6 +100,19 @@ describe('LandingPage', () => {
100100
expect(input.value).toBe('');
101101
});
102102

103+
it('renders recent searches and applies a recent search when clicked', () => {
104+
render(<LandingPage />);
105+
const input = screen.getByPlaceholderText('Enter GitHub Username') as HTMLInputElement;
106+
const octocatButton = screen.getByRole('button', { name: 'octocat' });
107+
108+
expect(octocatButton).toBeDefined();
109+
expect(screen.getByRole('button', { name: 'Clear' })).toBeDefined();
110+
111+
fireEvent.click(octocatButton);
112+
113+
expect(input.value).toBe('octocat');
114+
});
115+
103116
it('renders an empty state before a username is entered', () => {
104117
render(<LandingPage />);
105118

0 commit comments

Comments
 (0)