chore: Update specs and warnings in console (#7467)

This commit is contained in:
Pranav Raj S
2023-07-05 18:32:55 -07:00
committed by GitHub
parent 3054a4cb59
commit 4e8d17f017
12 changed files with 101 additions and 122 deletions

View File

@@ -1,52 +1,45 @@
import TemplateParser from '../../../../dashboard/components/widgets/conversation/WhatsappTemplates/TemplateParser.vue';
import { mount, createLocalVue } from '@vue/test-utils';
import { shallowMount, createLocalVue } from '@vue/test-utils';
import { templates } from './fixtures';
const localVue = createLocalVue();
import VueI18n from 'vue-i18n';
import Vue from 'vue';
import Vuelidate from 'vuelidate';
Vue.use(Vuelidate);
import i18n from 'dashboard/i18n';
localVue.use(VueI18n);
localVue.use(Vuelidate);
const i18nConfig = new VueI18n({
locale: 'en',
messages: i18n,
});
const i18nConfig = new VueI18n({ locale: 'en', messages: i18n });
const config = {
localVue,
i18n: i18nConfig,
stubs: {
WootButton: { template: '<button />' },
WootInput: { template: '<input />' },
},
};
describe('#WhatsAppTemplates', () => {
it('returns all variables from a template string', () => {
const wrapper = mount(TemplateParser, {
localVue,
propsData: {
template: templates[0],
},
i18n: i18nConfig,
const wrapper = shallowMount(TemplateParser, {
...config,
propsData: { template: templates[0] },
});
expect(wrapper.vm.variables).toEqual(['{{1}}', '{{2}}', '{{3}}']);
});
it('returns no variables from a template string if it does not contain variables', () => {
const wrapper = mount(TemplateParser, {
localVue,
propsData: {
template: templates[12],
},
i18n: i18nConfig,
const wrapper = shallowMount(TemplateParser, {
...config,
propsData: { template: templates[12] },
});
expect(wrapper.vm.variables).toBeNull();
});
it('returns the body of a template', () => {
const wrapper = mount(TemplateParser, {
localVue,
propsData: {
template: templates[1],
},
i18n: i18nConfig,
const wrapper = shallowMount(TemplateParser, {
...config,
propsData: { template: templates[1] },
});
const expectedOutput = templates[1].components.find(i => i.type === 'BODY')
.text;
@@ -54,17 +47,12 @@ describe('#WhatsAppTemplates', () => {
});
it('generates the templates from variable input', async () => {
const wrapper = mount(TemplateParser, {
localVue,
propsData: {
template: templates[0],
},
const wrapper = shallowMount(TemplateParser, {
...config,
propsData: { template: templates[0] },
data: () => {
return {
processedParams: {},
};
return { processedParams: {} };
},
i18n: i18nConfig,
});
await wrapper.setData({
processedParams: { '1': 'abc', '2': 'xyz', '3': 'qwerty' },