debian-mirror-gitlab/spec/frontend/ci/artifacts/components/feedback_banner_spec.js

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

60 lines
1.6 KiB
JavaScript
Raw Normal View History

2023-03-17 16:20:25 +05:30
import { GlBanner } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
2023-06-20 00:43:36 +05:30
import FeedbackBanner from '~/ci/artifacts/components/feedback_banner.vue';
2023-03-17 16:20:25 +05:30
import { makeMockUserCalloutDismisser } from 'helpers/mock_user_callout_dismisser';
import {
I18N_FEEDBACK_BANNER_TITLE,
I18N_FEEDBACK_BANNER_BUTTON,
FEEDBACK_URL,
2023-06-20 00:43:36 +05:30
} from '~/ci/artifacts/constants';
2023-03-17 16:20:25 +05:30
const mockBannerImagePath = 'banner/image/path';
describe('Artifacts management feedback banner', () => {
let wrapper;
let userCalloutDismissSpy;
const findBanner = () => wrapper.findComponent(GlBanner);
const createComponent = ({ shouldShowCallout = true } = {}) => {
userCalloutDismissSpy = jest.fn();
wrapper = shallowMount(FeedbackBanner, {
provide: {
artifactsManagementFeedbackImagePath: mockBannerImagePath,
},
stubs: {
UserCalloutDismisser: makeMockUserCalloutDismisser({
dismiss: userCalloutDismissSpy,
shouldShowCallout,
}),
},
});
};
it('is displayed with the correct props', () => {
createComponent();
expect(findBanner().props()).toMatchObject({
title: I18N_FEEDBACK_BANNER_TITLE,
buttonText: I18N_FEEDBACK_BANNER_BUTTON,
buttonLink: FEEDBACK_URL,
svgPath: mockBannerImagePath,
});
});
it('dismisses the callout when closed', () => {
createComponent();
findBanner().vm.$emit('close');
expect(userCalloutDismissSpy).toHaveBeenCalled();
});
it('is not displayed once it has been dismissed', () => {
createComponent({ shouldShowCallout: false });
expect(findBanner().exists()).toBe(false);
});
});