Commit e2b538d4 authored by Vitaly Slobodin's avatar Vitaly Slobodin

Adjust specs after rebase

parent ac047c40
<script>
import { GlAlert, GlSprintf } from '@gitlab/ui';
import Cookie from 'js-cookie';
import { helpPagePath } from '~/helpers/help_page_helper';
import { formatDate, getDayDifference } from '~/lib/utils/datetime_utility';
import { s__, __, sprintf } from '~/locale';
......@@ -18,6 +19,10 @@ it will be charged. Otherwise, you will receive an invoice.`),
const CONTACT_SUPPORT_URL = 'https://about.gitlab.com/support/#contact-support';
const qrtlyReconciliationHelpPageUrl = helpPagePath('subscriptions/self_managed/index', {
anchor: 'quarterly-subscription-reconciliation',
});
export default {
name: 'QrtlyReconciliationAlert',
components: {
......@@ -26,7 +31,7 @@ export default {
},
props: {
date: {
type: Number,
type: Date,
required: true,
},
cookieKey: {
......@@ -51,6 +56,7 @@ export default {
},
i18n,
CONTACT_SUPPORT_URL,
qrtlyReconciliationHelpPageUrl,
};
</script>
......@@ -60,6 +66,7 @@ export default {
variant="info"
:title="alertTitle"
:primary-button-text="$options.i18n.learnMore"
:primary-button-link="$options.qrtlyReconciliationHelpPageUrl"
:secondary-button-text="$options.i18n.contactSupport"
:secondary-button-link="$options.CONTACT_SUPPORT_URL"
@dismiss="handleDismiss"
......
......@@ -13,7 +13,7 @@ export const initQrtlyReconciliationAlert = (selector = '#js-qrtly-reconciliatio
render(createElement) {
return createElement(QrtlyReconciliationAlert, {
props: {
date: Date.parse(el.dataset.reconciliationDate),
date: new Date(el.dataset.reconciliationDate),
cookieKey: el.dataset.cookieKey,
},
});
......
import { GlAlert } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import Cookie from 'js-cookie';
import QrtlyReconciliationAlert from 'ee/admin/components/qrtly_reconciliation_alert.vue';
jest.mock('js-cookie', () => ({
set: jest.fn(),
}));
describe('Qrtly Reconciliation Alert', () => {
let wrapper;
const reconciliationDate = new Date('2020-01-01');
const reconciliationDate = new Date('2020-07-10');
const createComponent = () => {
return shallowMount(QrtlyReconciliationAlert, {
propsData: {
cookieKey: 'key',
date: reconciliationDate,
},
});
......@@ -24,7 +30,28 @@ describe('Qrtly Reconciliation Alert', () => {
describe('Rendering', () => {
it('renders alert title with date', () => {
expect(wrapper.find(GlAlert).attributes('title')).toContain(`occur on ${reconciliationDate}`);
expect(wrapper.find(GlAlert).attributes('title')).toContain(`occur on 2020-07-10`);
});
it('has the correct link to the help page', () => {
expect(wrapper.find(GlAlert).attributes('primarybuttonlink')).toBe(
'/help/subscriptions/self_managed/index#quarterly-subscription-reconciliation',
);
});
it('has the correct link to contact support', () => {
expect(wrapper.find(GlAlert).attributes('secondarybuttonlink')).toBe(
'https://about.gitlab.com/support/#contact-support',
);
});
});
describe('methods', () => {
it('sets the cookie on dismis', () => {
wrapper.find(GlAlert).vm.$emit('dismiss');
expect(Cookie.set).toHaveBeenCalledTimes(1);
expect(Cookie.set).toHaveBeenCalledWith('key', true, { expires: 4 });
});
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment