debian-mirror-gitlab/spec/frontend/vue_shared/components/dismissible_alert_spec.js
2020-03-09 13:42:32 +05:30

57 lines
1.3 KiB
JavaScript

import { shallowMount } from '@vue/test-utils';
import { GlAlert } from '@gitlab/ui';
import DismissibleAlert from '~/vue_shared/components/dismissible_alert.vue';
const TEST_HTML = 'Hello World! <strong>Foo</strong>';
describe('vue_shared/components/dismissible_alert', () => {
const testAlertProps = {
primaryButtonText: 'Lorem ipsum',
primaryButtonLink: '/lorem/ipsum',
};
let wrapper;
const createComponent = (props = {}) => {
wrapper = shallowMount(DismissibleAlert, {
propsData: {
html: TEST_HTML,
...testAlertProps,
...props,
},
});
};
afterEach(() => {
wrapper.destroy();
});
const findAlert = () => wrapper.find(GlAlert);
describe('with default', () => {
beforeEach(() => {
createComponent();
});
it('shows alert', () => {
const alert = findAlert();
expect(alert.exists()).toBe(true);
expect(alert.props()).toEqual(expect.objectContaining(testAlertProps));
});
it('shows given HTML', () => {
expect(findAlert().html()).toContain(TEST_HTML);
});
describe('when dismissed', () => {
beforeEach(() => {
findAlert().vm.$emit('dismiss');
});
it('hides the alert', () => {
expect(findAlert().exists()).toBe(false);
});
});
});
});