debian-mirror-gitlab/spec/frontend/batch_comments/components/drafts_count_spec.js

41 lines
988 B
JavaScript
Raw Normal View History

2022-04-04 11:22:00 +05:30
import Vue, { nextTick } from 'vue';
2020-06-23 00:09:42 +05:30
import { mountComponentWithStore } from 'helpers/vue_mount_component_helper';
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', () => {
let vm;
let Component;
beforeAll(() => {
Component = Vue.extend(DraftsCount);
});
beforeEach(() => {
const store = createStore();
store.state.batchComments.drafts.push('comment');
vm = mountComponentWithStore(Component, { store });
});
afterEach(() => {
vm.$destroy();
});
it('renders count', () => {
2020-10-24 23:57:45 +05:30
expect(vm.$el.textContent).toContain('1');
2020-06-23 00:09:42 +05:30
});
2022-04-04 11:22:00 +05:30
it('renders screen reader text', async () => {
2020-06-23 00:09:42 +05:30
const el = vm.$el.querySelector('.sr-only');
expect(el.textContent).toContain('draft');
vm.$store.state.batchComments.drafts.push('comment 2');
2022-04-04 11:22:00 +05:30
await nextTick();
expect(el.textContent).toContain('drafts');
2020-06-23 00:09:42 +05:30
});
});