2022-11-25 23:54:43 +05:30
|
|
|
import { nextTick } from 'vue';
|
|
|
|
import { mount } from '@vue/test-utils';
|
2020-10-24 23:57:45 +05:30
|
|
|
import DraftsCount from '~/batch_comments/components/drafts_count.vue';
|
2020-06-23 00:09:42 +05:30
|
|
|
import { createStore } from '~/batch_comments/stores';
|
|
|
|
|
|
|
|
describe('Batch comments drafts count component', () => {
|
2022-11-25 23:54:43 +05:30
|
|
|
let store;
|
|
|
|
let wrapper;
|
2020-06-23 00:09:42 +05:30
|
|
|
|
|
|
|
beforeEach(() => {
|
2022-11-25 23:54:43 +05:30
|
|
|
store = createStore();
|
2020-06-23 00:09:42 +05:30
|
|
|
|
|
|
|
store.state.batchComments.drafts.push('comment');
|
|
|
|
|
2022-11-25 23:54:43 +05:30
|
|
|
wrapper = mount(DraftsCount, { store });
|
2020-06-23 00:09:42 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
2022-11-25 23:54:43 +05:30
|
|
|
wrapper.destroy();
|
2020-06-23 00:09:42 +05:30
|
|
|
});
|
|
|
|
|
|
|
|
it('renders count', () => {
|
2022-11-25 23:54:43 +05:30
|
|
|
expect(wrapper.text()).toContain('1');
|
2020-06-23 00:09:42 +05:30
|
|
|
});
|
|
|
|
|
2022-04-04 11:22:00 +05:30
|
|
|
it('renders screen reader text', async () => {
|
2022-11-25 23:54:43 +05:30
|
|
|
const el = wrapper.find('.sr-only');
|
2020-06-23 00:09:42 +05:30
|
|
|
|
2022-11-25 23:54:43 +05:30
|
|
|
expect(el.text()).toContain('draft');
|
2020-06-23 00:09:42 +05:30
|
|
|
|
2022-11-25 23:54:43 +05:30
|
|
|
store.state.batchComments.drafts.push('comment 2');
|
2022-04-04 11:22:00 +05:30
|
|
|
await nextTick();
|
2022-11-25 23:54:43 +05:30
|
|
|
|
|
|
|
expect(el.text()).toContain('drafts');
|
2020-06-23 00:09:42 +05:30
|
|
|
});
|
|
|
|
});
|