Skip to content

Commit

Permalink
refactor: category-breadcrumbs test refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Devitsky authored and bartoszherba committed May 13, 2022
1 parent 4bce31b commit ef4df4a
Showing 1 changed file with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,16 @@ jest.mock('@nuxtjs/composition-api', () => {
jest.mock('~/composables');
jest.mock('~/modules/catalog/category/helpers/useTraverseCategory');

describe('CategoryBreadcrumbs.vue', () => {
beforeEach(() => {
const { useContext } = composables;
jest.resetAllMocks();
(useContext as jest.Mock).mockReturnValue({
localePath: jest.fn((path: string) => path),
});
(useUiHelpers as jest.Mock).mockReturnValue({
getCatLink: jest.fn(
(category: CategoryTree): string => `/c/${category.url_path}${category.url_suffix || ''}`,
),
});
});
(composables.useContext as jest.Mock).mockReturnValue({
localePath: jest.fn((path: string) => path),
});
(useUiHelpers as jest.Mock).mockReturnValue({
getCatLink: jest.fn(
(category: CategoryTree): string => `/c/${category.url_path}${category.url_suffix || ''}`,
),
});

describe('CategoryBreadcrumbs.vue', () => {
it('Breadcrumbs should not render if there is only a first level category', () => {
(useTraverseCategory as jest.Mock).mockReturnValue(useTraverseCategoryMock(categoryAncestorsFirstLevelMock));
const wrapper = mount(CategoryBreadcrumbs);
Expand Down

0 comments on commit ef4df4a

Please sign in to comment.