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

40 lines
1.1 KiB
JavaScript
Raw Normal View History

2021-01-03 14:25:43 +05:30
import { GlDropdown, GlDropdownItem } from '@gitlab/ui';
2021-03-11 19:13:27 +05:30
import { shallowMount, createLocalVue } from '@vue/test-utils';
import Vuex from 'vuex';
2020-10-24 23:57:45 +05:30
import PreviewDropdown from '~/batch_comments/components/preview_dropdown.vue';
2020-06-23 00:09:42 +05:30
import { createStore } from '~/mr_notes/stores';
import '~/behaviors/markdown/render_gfm';
import { createDraft } from '../mock_data';
2021-01-03 14:25:43 +05:30
const localVue = createLocalVue();
localVue.use(Vuex);
2020-06-23 00:09:42 +05:30
describe('Batch comments publish dropdown component', () => {
2021-01-03 14:25:43 +05:30
let wrapper;
2020-06-23 00:09:42 +05:30
2021-01-03 14:25:43 +05:30
function createComponent() {
2020-06-23 00:09:42 +05:30
const store = createStore();
store.state.batchComments.drafts.push(createDraft(), { ...createDraft(), id: 2 });
2021-01-03 14:25:43 +05:30
wrapper = shallowMount(PreviewDropdown, {
store,
});
2020-06-23 00:09:42 +05:30
}
afterEach(() => {
2021-01-03 14:25:43 +05:30
wrapper.destroy();
2020-06-23 00:09:42 +05:30
});
it('renders list of drafts', () => {
createComponent();
2021-01-03 14:25:43 +05:30
expect(wrapper.findAll(GlDropdownItem).length).toBe(2);
2020-06-23 00:09:42 +05:30
});
2021-01-03 14:25:43 +05:30
it('renders draft count in dropdown title', () => {
2020-06-23 00:09:42 +05:30
createComponent();
2021-01-03 14:25:43 +05:30
expect(wrapper.find(GlDropdown).props('headerText')).toEqual('2 pending comments');
2020-06-23 00:09:42 +05:30
});
});