2020-10-02 08:09:03 -04:00
|
|
|
import { GlDropdown, GlDropdownItem } from '@gitlab/ui';
|
2022-01-21 10:13:54 -05:00
|
|
|
import { shallowMount } from '@vue/test-utils';
|
|
|
|
import Vue from 'vue';
|
2021-02-14 13:09:20 -05:00
|
|
|
import Vuex from 'vuex';
|
2020-08-17 17:09:56 -04:00
|
|
|
import PreviewDropdown from '~/batch_comments/components/preview_dropdown.vue';
|
2020-06-01 02:08:21 -04:00
|
|
|
import { createStore } from '~/mr_notes/stores';
|
|
|
|
import '~/behaviors/markdown/render_gfm';
|
|
|
|
import { createDraft } from '../mock_data';
|
|
|
|
|
2022-01-21 10:13:54 -05:00
|
|
|
Vue.use(Vuex);
|
2020-10-02 08:09:03 -04:00
|
|
|
|
2020-06-01 02:08:21 -04:00
|
|
|
describe('Batch comments publish dropdown component', () => {
|
2020-10-02 08:09:03 -04:00
|
|
|
let wrapper;
|
2020-06-01 02:08:21 -04:00
|
|
|
|
2020-10-02 08:09:03 -04:00
|
|
|
function createComponent() {
|
2020-06-01 02:08:21 -04:00
|
|
|
const store = createStore();
|
|
|
|
store.state.batchComments.drafts.push(createDraft(), { ...createDraft(), id: 2 });
|
|
|
|
|
2020-10-02 08:09:03 -04:00
|
|
|
wrapper = shallowMount(PreviewDropdown, {
|
|
|
|
store,
|
|
|
|
});
|
2020-06-01 02:08:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
afterEach(() => {
|
2020-10-02 08:09:03 -04:00
|
|
|
wrapper.destroy();
|
2020-06-01 02:08:21 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('renders list of drafts', () => {
|
|
|
|
createComponent();
|
|
|
|
|
2020-10-02 08:09:03 -04:00
|
|
|
expect(wrapper.findAll(GlDropdownItem).length).toBe(2);
|
2020-06-01 02:08:21 -04:00
|
|
|
});
|
|
|
|
|
2020-10-02 08:09:03 -04:00
|
|
|
it('renders draft count in dropdown title', () => {
|
2020-06-01 02:08:21 -04:00
|
|
|
createComponent();
|
|
|
|
|
2020-10-02 08:09:03 -04:00
|
|
|
expect(wrapper.find(GlDropdown).props('headerText')).toEqual('2 pending comments');
|
2020-06-01 02:08:21 -04:00
|
|
|
});
|
|
|
|
});
|