2021-08-06 21:14:33 +01:00
|
|
|
// Copyright (C) 2021 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
import Vuex from 'vuex';
|
2022-09-08 15:11:09 +01:00
|
|
|
import { createLocalVue, shallowMount } from '@vue/test-utils';
|
2021-08-06 21:14:33 +01:00
|
|
|
|
2022-09-08 15:11:09 +01:00
|
|
|
import { PaymentsMock } from '../../../mock/api/payments';
|
2021-08-06 21:14:33 +01:00
|
|
|
|
|
|
|
import { appStateModule } from '@/store/modules/appState';
|
|
|
|
import { APP_STATE_ACTIONS } from '@/utils/constants/actionNames';
|
|
|
|
import { makePaymentsModule } from '@/store/modules/payments';
|
|
|
|
import { Coupon, CouponDuration } from '@/types/payments';
|
|
|
|
|
2022-09-08 15:11:09 +01:00
|
|
|
import CouponArea from '@/components/account/billing/coupons/CouponArea.vue';
|
|
|
|
|
2021-08-06 21:14:33 +01:00
|
|
|
const localVue = createLocalVue();
|
2022-04-07 12:04:24 +01:00
|
|
|
localVue.use(Vuex);
|
|
|
|
|
2021-08-06 21:14:33 +01:00
|
|
|
const paymentsApi = new PaymentsMock();
|
|
|
|
const paymentsModule = makePaymentsModule(paymentsApi);
|
|
|
|
paymentsApi.setMockCoupon(new Coupon(
|
|
|
|
'',
|
|
|
|
'PROMO_CODE',
|
|
|
|
'Coupon Name',
|
|
|
|
123,
|
|
|
|
0,
|
|
|
|
new Date(2021, 9, 1),
|
|
|
|
new Date(2021, 11, 1),
|
2022-09-08 15:11:09 +01:00
|
|
|
CouponDuration.Repeating,
|
2021-08-06 21:14:33 +01:00
|
|
|
));
|
|
|
|
|
2022-09-08 15:11:09 +01:00
|
|
|
const store = new Vuex.Store({ modules: { paymentsModule, appStateModule } });
|
2021-08-06 21:14:33 +01:00
|
|
|
store.commit(APP_STATE_ACTIONS.SET_COUPON_CODE_BILLING_UI_STATUS, true);
|
|
|
|
|
|
|
|
describe('CouponArea', (): void => {
|
|
|
|
it('renders correctly', async (): Promise<void> => {
|
|
|
|
const wrapper = shallowMount(CouponArea, {
|
|
|
|
localVue,
|
|
|
|
store,
|
|
|
|
});
|
|
|
|
|
|
|
|
await wrapper.setData({ isCouponFetching: false });
|
|
|
|
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
});
|