import {mount,} from "@vue/test-utils"; import "@/setup" import {componentByTemplate} from "@/utils"; describe('scope', () => { it('vars and form', async () => { const form = new FormData() const MyComp = componentByTemplate(`
{{ vars.hello }}
{{ locals.hello }}
{{ plaidForm.get("Name") }}
{{ plaidForm.get("Name") }}
{{plaidForm.get("Name")}}
`, form) const Root = { components: { "mycomp": MyComp, }, template: ` `, provide() { return { vars: {}, } }, } const wrapper = await mount(Root) console.log(wrapper.html()) const btn: any = wrapper.find("#l1Btn") await btn.trigger("click") const l1: any = wrapper.find("#l1") expect(l1.text()).toEqual(`456`); const btn2: any = wrapper.find("#l2Btn") await btn2.trigger("click") const l2: any = wrapper.find("#l2") expect(l2.text()).toEqual(`999`); const btn3: any = wrapper.find("#l3Btn") const input4: any = wrapper.find("#input4") await input4.setValue("CCC") await btn3.trigger("click") console.log(wrapper.html()) const l3: any = wrapper.find("#l3") expect(l2.text()).toEqual(`AAA`); expect(l3.text()).toEqual(`AAA`); }) })