debian-mirror-gitlab/spec/frontend/vue_shared/components/dismissible_container_spec.js

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

56 lines
1.4 KiB
JavaScript
Raw Normal View History

2020-10-24 23:57:45 +05:30
import { shallowMount } from '@vue/test-utils';
2021-03-11 19:13:27 +05:30
import MockAdapter from 'axios-mock-adapter';
2020-10-24 23:57:45 +05:30
import axios from '~/lib/utils/axios_utils';
2023-04-23 21:23:45 +05:30
import { HTTP_STATUS_OK } from '~/lib/utils/http_status';
2020-10-24 23:57:45 +05:30
import dismissibleContainer from '~/vue_shared/components/dismissible_container.vue';
describe('DismissibleContainer', () => {
let wrapper;
const propsData = {
path: 'some/path',
featureId: 'some-feature-id',
};
describe('template', () => {
const findBtn = () => wrapper.find('[data-testid="close"]');
let mockAxios;
beforeEach(() => {
mockAxios = new MockAdapter(axios);
wrapper = shallowMount(dismissibleContainer, { propsData });
});
afterEach(() => {
mockAxios.restore();
});
it('successfully dismisses', () => {
2023-04-23 21:23:45 +05:30
mockAxios.onPost(propsData.path).replyOnce(HTTP_STATUS_OK);
2020-10-24 23:57:45 +05:30
const button = findBtn();
button.trigger('click');
2022-08-27 11:52:29 +05:30
expect(wrapper.emitted().dismiss).toEqual(expect.any(Array));
2020-10-24 23:57:45 +05:30
});
});
describe('slots', () => {
const slots = {
title: 'Foo Title',
default: 'default slot',
};
2021-03-08 18:12:59 +05:30
it.each(Object.keys(slots))('renders the %s slot', (slot) => {
2020-10-24 23:57:45 +05:30
const slotContent = slots[slot];
wrapper = shallowMount(dismissibleContainer, {
propsData,
slots: {
[slot]: `<span>${slotContent}</span>`,
},
});
expect(wrapper.text()).toContain(slotContent);
});
});
});