From cc1bd39ee89f8aa0c7de9a9d8304b1ecc47f7c60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Renato=20de=20Le=C3=A3o?= Date: Tue, 3 Jan 2023 18:30:21 +0000 Subject: [PATCH] test: add failing global mocks scenario --- tests/mountingOptions/mocks.spec.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/mountingOptions/mocks.spec.ts b/tests/mountingOptions/mocks.spec.ts index 2d9d410b1..c07bb5937 100644 --- a/tests/mountingOptions/mocks.spec.ts +++ b/tests/mountingOptions/mocks.spec.ts @@ -101,4 +101,29 @@ describe('mocks', () => { expect(wrapper.text()).toContain('hello') expect(wrapper.text()).toContain('mocked') }) + + it('mocks a global function in an option component which includes the setup() option', () => { + const ComponentWithI18nAndSetupOption = defineComponent({ + setup: () => ({ + hello: 'hello' + }), + template: ` +
{{ hello }}
+ + +
{{ $t('world') }}
+ ` + }) + + const wrapper = mount(ComponentWithI18nAndSetupOption, { + global: { + mocks: { + $t: () => 'mocked' + } + } + }) + + expect(wrapper.text()).toContain('hello') + expect(wrapper.text()).toContain('mocked') + }) })