added test

Signed-off-by: npiyush97 <npiyush35@gmail.com>
This commit is contained in:
npiyush97
2024-03-28 00:32:02 +05:30
parent 47418403a4
commit c77dff47f6
2 changed files with 10 additions and 3 deletions
@@ -95,4 +95,13 @@ describe('<HeaderTabs />', () => {
await user.click(rendered.getByText('Docs'));
expect(mockOnChange).toHaveBeenCalledTimes(1);
});
it('should render 2 nav tabs', async () => {
const rendered = await renderInTestApp(<HeaderTabs tabs={mockTabs} />);
const tabs = rendered.queryAllByTestId(id => id.startsWith('header-tab'));
expect(tabs).toHaveLength(2);
tabs.forEach(tab => {
expect(tab.tagName.toLocaleLowerCase('en-US')).toBe('a');
});
});
});
@@ -97,9 +97,7 @@ export function HeaderTabs(props: HeaderTabsProps) {
}
}, [selectedIndex]);
function removeLeadingSlash(path: string) {
let newPath = path;
newPath = path.replace(/^\//, '');
return newPath;
return path.replace(/^\//, '');
}
return (
<Box className={styles.tabsWrapper}>