-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
83e861f
commit 1d24428
Showing
8 changed files
with
1,044 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import Vuex from 'vuex'; | ||
import { mount, createLocalVue } from '@vue/test-utils'; | ||
import Card from '@/components/whatsAppCatalogs/Card.vue'; | ||
import '@weni/unnnic-system'; | ||
import i18n from '@/utils/plugins/i18n'; | ||
|
||
const localVue = createLocalVue(); | ||
localVue.use(Vuex); | ||
|
||
const mountComponent = async ({ | ||
errorDisableCatalog = false, | ||
enabledCart = false, | ||
catalog = {}, | ||
} = {}) => { | ||
const state = { | ||
errorDisableCatalog, | ||
}; | ||
|
||
const actions = { | ||
disableWhatsAppCloudCatalogs: jest.fn(), | ||
}; | ||
|
||
const store = new Vuex.Store({ | ||
modules: { | ||
WhatsAppCloud: { | ||
namespaced: true, | ||
actions, | ||
state, | ||
}, | ||
}, | ||
}); | ||
|
||
const wrapper = mount(Card, { | ||
localVue, | ||
store, | ||
i18n, | ||
propsData: { | ||
catalog, | ||
enabledCart, | ||
}, | ||
}); | ||
|
||
return { wrapper, actions, state }; | ||
}; | ||
|
||
describe('components/whatsAppCatalog/Card.vue', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should be rendered properly', async () => { | ||
const { wrapper } = await mountComponent(); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
describe('catalog connect emits', () => { | ||
it('should emit enable on toggle catalog connect', async () => { | ||
const { wrapper } = await mountComponent(); | ||
const toggle = wrapper.findComponent({ ref: 'catalogConnectSwitch' }); | ||
toggle.vm.$emit('input', true); | ||
expect(wrapper.emitted().enable).toBeTruthy(); | ||
}); | ||
|
||
it('should emit disable on toggle catalog connect', async () => { | ||
const { wrapper } = await mountComponent(); | ||
const toggle = wrapper.findComponent({ ref: 'catalogConnectSwitch' }); | ||
toggle.vm.$emit('input', false); | ||
expect(wrapper.emitted().disable).toBeTruthy(); | ||
}); | ||
}); | ||
|
||
describe('toggleCart emit', () => { | ||
it('should emit toggleCart on switch click', async () => { | ||
const { wrapper } = await mountComponent({ catalog: { is_connected: true } }); | ||
const toggle = wrapper.findComponent({ ref: 'cartEnableSwitch' }); | ||
toggle.trigger('click'); | ||
expect(wrapper.emitted().toggleCart).toBeTruthy(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.