Skip to content

Commit 2a3cff2

Browse files
fix
1 parent 64859d5 commit 2a3cff2

File tree

4 files changed

+5
-14
lines changed

4 files changed

+5
-14
lines changed

components/Common/CategoriesSelector/index.test.tsx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,4 @@ describe('CategoriesSelector', () => {
3939

4040
unmount();
4141
});
42-
43-
it('should have active class for first category if no active category', () => {
44-
const { container, unmount } = render(
45-
<CategoriesSelector categories={mockCategories} currentCategories={[]} />
46-
);
47-
const firstCategory = container.querySelector('.active');
48-
49-
assert.strictEqual(firstCategory?.textContent, 'category1');
50-
51-
unmount();
52-
});
5342
});
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
exports[`CategoriesSelector > should render with an active category 1`] = `
2-
"<ul class=\\"categoriesSelector\\"><li class=\\"item active\\"><a href=\\"/article/slug1\\">category1</a></li><li class=\\"item\\"><a href=\\"/article/slug2\\">category2</a></li></ul>"
2+
"<ul class=\\"mb-4 flex space-x-2 border-green-400 border-b-4 text-gray-800 dark:border-green-600 dark:text-gray-200\\"><li class=\\"flex cursor-pointer items-center rounded-t-md px-2 py-1 transition duration-200 hover:bg-green-400 hover:text-white dark:hover:bg-green-600 dark:hover:text-white bg-green-400 text-white dark:bg-green-600\\" data-test-current-category=\\"true\\" aria-current=\\"true\\"><a href=\\"/article/slug1\\">category1</a></li><li class=\\"flex cursor-pointer items-center rounded-t-md px-2 py-1 transition duration-200 hover:bg-green-400 hover:text-white dark:hover:bg-green-600 dark:hover:text-white\\" data-test-current-category=\\"false\\" aria-current=\\"false\\"><a href=\\"/article/slug2\\">category2</a></li></ul>"
33
`;
44

55
exports[`CategoriesSelector > should render with no active category 1`] = `
6-
"<ul class=\\"categoriesSelector\\"><li class=\\"item active\\"><a href=\\"/article/slug1\\">category1</a></li><li class=\\"item\\"><a href=\\"/article/slug2\\">category2</a></li></ul>"
6+
"<ul class=\\"mb-4 flex space-x-2 border-green-400 border-b-4 text-gray-800 dark:border-green-600 dark:text-gray-200\\"><li class=\\"flex cursor-pointer items-center rounded-t-md px-2 py-1 transition duration-200 hover:bg-green-400 hover:text-white dark:hover:bg-green-600 dark:hover:text-white bg-green-400 text-white dark:bg-green-600\\" data-test-current-category=\\"false\\" aria-current=\\"false\\"><a href=\\"/article/slug1\\">category1</a></li><li class=\\"flex cursor-pointer items-center rounded-t-md px-2 py-1 transition duration-200 hover:bg-green-400 hover:text-white dark:hover:bg-green-600 dark:hover:text-white\\" data-test-current-category=\\"false\\" aria-current=\\"false\\"><a href=\\"/article/slug2\\">category2</a></li></ul>"
77
`;

components/Common/CategoriesSelector/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ export const CategoriesSelector: FC<CategoriesSelectorProps> = ({
2525
currentCategories.includes(category.slug),
2626
}
2727
)}
28+
data-test-current-category={currentCategories.includes(category.slug)}
29+
aria-current={currentCategories.includes(category.slug)}
2830
>
2931
<a href={`/article/${category.slug}`.replace(/\/$/, '')}>
3032
{category.category}

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)