2022-10-04 11:09:33 -04:00
|
|
|
import { nextTick } from 'vue';
|
|
|
|
import { mount } from '@vue/test-utils';
|
2020-08-17 17:09:56 -04:00
|
|
|
import DraftsCount from '~/batch_comments/components/drafts_count.vue';
|
2020-06-01 02:08:21 -04:00
|
|
|
import { createStore } from '~/batch_comments/stores';
|
|
|
|
|
|
|
|
describe('Batch comments drafts count component', () => {
|
2022-10-04 11:09:33 -04:00
|
|
|
let store;
|
|
|
|
let wrapper;
|
2020-06-01 02:08:21 -04:00
|
|
|
|
|
|
|
beforeEach(() => {
|
2022-10-04 11:09:33 -04:00
|
|
|
store = createStore();
|
2020-06-01 02:08:21 -04:00
|
|
|
|
|
|
|
store.state.batchComments.drafts.push('comment');
|
|
|
|
|
2022-10-04 11:09:33 -04:00
|
|
|
wrapper = mount(DraftsCount, { store });
|
2020-06-01 02:08:21 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() => {
|
2022-10-04 11:09:33 -04:00
|
|
|
wrapper.destroy();
|
2020-06-01 02:08:21 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('renders count', () => {
|
2022-10-04 11:09:33 -04:00
|
|
|
expect(wrapper.text()).toContain('1');
|
2020-06-01 02:08:21 -04:00
|
|
|
});
|
|
|
|
|
2022-01-25 10:12:32 -05:00
|
|
|
it('renders screen reader text', async () => {
|
2022-10-04 11:09:33 -04:00
|
|
|
const el = wrapper.find('.sr-only');
|
2020-06-01 02:08:21 -04:00
|
|
|
|
2022-10-04 11:09:33 -04:00
|
|
|
expect(el.text()).toContain('draft');
|
2020-06-01 02:08:21 -04:00
|
|
|
|
2022-10-04 11:09:33 -04:00
|
|
|
store.state.batchComments.drafts.push('comment 2');
|
2022-01-25 10:12:32 -05:00
|
|
|
await nextTick();
|
2022-10-04 11:09:33 -04:00
|
|
|
|
|
|
|
expect(el.text()).toContain('drafts');
|
2020-06-01 02:08:21 -04:00
|
|
|
});
|
|
|
|
});
|