From 97dbb13e9bb69d11a83c6b2b60ba08dab402b97e Mon Sep 17 00:00:00 2001 From: Diego Alba <72459310+Diegoalbag@users.noreply.github.com> Date: Fri, 29 Apr 2022 06:21:25 -0400 Subject: [PATCH] test: CategoryEmptyResults component (#934) --- packages/theme/jest-setup.js | 3 +++ .../__tests__/CategoryEmptyResults.spec.ts | 24 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 packages/theme/modules/catalog/category/components/__tests__/CategoryEmptyResults.spec.ts diff --git a/packages/theme/jest-setup.js b/packages/theme/jest-setup.js index 16ce89e48..49e2bb7d2 100644 --- a/packages/theme/jest-setup.js +++ b/packages/theme/jest-setup.js @@ -5,6 +5,9 @@ import { config } from '@vue/test-utils'; config.stubs = { NuxtImg: { render(h) { return h('img'); } }, }; +config.mocks = { + $t: (text) => text +} const $vsf = { $magento: { diff --git a/packages/theme/modules/catalog/category/components/__tests__/CategoryEmptyResults.spec.ts b/packages/theme/modules/catalog/category/components/__tests__/CategoryEmptyResults.spec.ts new file mode 100644 index 000000000..f0710c9a4 --- /dev/null +++ b/packages/theme/modules/catalog/category/components/__tests__/CategoryEmptyResults.spec.ts @@ -0,0 +1,24 @@ +import CategoryEmptyResults from '../CategoryEmptyResults.vue'; +import { render } from '~/test-utils'; +import { expect } from '@jest/globals'; + +describe('CategoryEmptyResults.vue', () => { + it('Renders with a default value', () => { + const { getByRole, queryByText } = render(CategoryEmptyResults); + + const svgImage = getByRole('img'); + const paragraph = queryByText(`We can't find products matching the selection.`); + + expect(svgImage).toBeDefined(); + expect(paragraph).toBeDefined(); + }); + + it('Renders content from the "default" slot', () => { + const wrapper = render(CategoryEmptyResults, { + slots: { + default: `
` + } + }); + expect(wrapper.html()).toContain(''); + }); +}); \ No newline at end of file