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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

40 lines
1 KiB
JavaScript
Raw Normal View History

2021-01-03 14:25:43 +05:30
import { GlDropdown, GlDropdownItem } 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 '~/behaviors/markdown/render_gfm';
import { createDraft } from '../mock_data';
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;
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();
2022-10-11 01:57:18 +05:30
expect(wrapper.findAllComponents(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();
2022-10-11 01:57:18 +05:30
expect(wrapper.findComponent(GlDropdown).props('headerText')).toEqual('2 pending comments');
2020-06-23 00:09:42 +05:30
});
});