2023-04-23 21:23:45 +05:30
|
|
|
import { GlDisclosureDropdown } from '@gitlab/ui';
|
2022-04-04 11:22:00 +05:30
|
|
|
import { shallowMount } from '@vue/test-utils';
|
|
|
|
import Vue from 'vue';
|
2021-03-11 19:13:27 +05:30
|
|
|
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 { createDraft } from '../mock_data';
|
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
jest.mock('~/behaviors/markdown/render_gfm');
|
|
|
|
|
2022-04-04 11:22:00 +05:30
|
|
|
Vue.use(Vuex);
|
2021-01-03 14:25:43 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
describe('Batch comments publish dropdown component', () => {
|
2021-01-03 14:25:43 +05:30
|
|
|
let wrapper;
|
2023-04-23 21:23:45 +05:30
|
|
|
const draft = createDraft();
|
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();
|
2023-04-23 21:23:45 +05:30
|
|
|
store.state.batchComments.drafts.push(draft, { ...draft, id: 2 });
|
2020-06-23 00:09:42 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
wrapper = shallowMount(PreviewDropdown, {
|
|
|
|
store,
|
2023-04-23 21:23:45 +05:30
|
|
|
stubs: { GlDisclosureDropdown },
|
2021-01-03 14:25:43 +05:30
|
|
|
});
|
2020-06-23 00:09:42 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
it('renders list of drafts', () => {
|
|
|
|
createComponent();
|
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
expect(wrapper.findComponent(GlDisclosureDropdown).props('items')).toMatchObject([
|
|
|
|
draft,
|
|
|
|
{ ...draft, id: 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();
|
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
expect(wrapper.findComponent(GlDisclosureDropdown).text()).toEqual('2 pending comments');
|
2020-06-23 00:09:42 +05:30
|
|
|
});
|
|
|
|
});
|