DigitalConsumer.ISS/src/layouts/payment-method/payment-method.spec.js
2024-02-08 11:12:18 -05:00

43 lines
1.4 KiB
JavaScript

// Components
import paymentMethod from '@/layouts/payment-method/payment-method.vue';
// Supporting Files
import { shallowMount } from '@vue/test-utils';
import { getMountOptions } from '@/helpers/unit-test-helper.js';
import { useMainStore } from '@/store';
import paymentMethods from '@/constants/payment-method-constants';
function setupMocks() {
const mountOptions = getMountOptions();
const wrapper = shallowMount(paymentMethod, mountOptions);
return { wrapper };
}
describe('payment-method.vue', () => {
test('getting payment method when method is pay later', async () => {
// Arrange
const { wrapper } = setupMocks();
const payLaterPaymentMethod = paymentMethods.PAY_AT_TIME_OF_SERVICE;
useMainStore().savePaymentMethodChoice(payLaterPaymentMethod);
// Act
const paymethod = wrapper.vm.getPaymentMethodFromStore();
// Assert
expect(paymethod).toBe(payLaterPaymentMethod);
});
test('getting payment method when method is pay in advance', async () => {
// Arrange
const { wrapper } = setupMocks();
const payInAdvancePaymentMethod = paymentMethods.CREDIT_CARD;
useMainStore().savePaymentMethodChoice(payInAdvancePaymentMethod);
// Act
const paymethod = wrapper.vm.getPaymentMethodFromStore();
// Assert
expect(paymethod).not.toBe(payInAdvancePaymentMethod);
});
});