import { mount } from '@vue/test-utils';
import inputButtonWrapperMixin from '@/mixins/input-button-wrapper-mixin';
import servicePackageRadio from '@/layouts/service-packages/service-package-question/service-package-radio/service-package-radio.vue';

const mockProps = {
    buttonLabel: 'buttonLabel test copy',
    buttonLabelAuxillaryCopy: 'buttonLabelAuxillaryCopy test copy',
    buttonLabelSubCopy: 'buttonLabelSubCopy test copy',
    buttonBodyCopy: '- buttonBodyCopy test copy - 2 - 3 - 4 - 5',
    buttonFooterCopy: 'buttonFooterCopy test copy'
};

/** @ignore */
function setupMocks({ mountOptionsMockData = {} }) {
    const wrapper = mount(servicePackageRadio, {
        ...mountOptionsMockData,
        mixins: [inputButtonWrapperMixin]
    });

    return { wrapper };
}

describe('service-package-radio.vue', () => {
    it('Should include buttonLabel in html', async () => {
    // Arrange
        const { wrapper } = setupMocks({
            mountOptionsMockData: {
                propsData: mockProps
            }
        });

        // Act
        const outputHtml = wrapper.html();

        // Assert
        expect(outputHtml).toEqual(expect.stringContaining(mockProps.buttonLabel));
    });

    it('Should include buttonLabelAuxillaryCopy in html', async () => {
    // Arrange
        const { wrapper } = setupMocks({
            mountOptionsMockData: {
                propsData: mockProps
            }
        });

        // Act
        const outputHtml = wrapper.html();

        // Assert
        expect(outputHtml).toEqual(expect.stringContaining(mockProps.buttonLabelAuxillaryCopy));
    });

    it('Should include buttonLabelSubCopy in html', async () => {
    // Arrange
        const { wrapper } = setupMocks({
            mountOptionsMockData: {
                propsData: mockProps
            }
        });

        // Act
        const outputHtml = wrapper.html();

        // Assert
        expect(outputHtml).toEqual(expect.stringContaining(mockProps.buttonLabelSubCopy));
    });
    it('Should include buttonFooterCopy in html', async () => {
    // Arrange
        const { wrapper } = setupMocks({
            mountOptionsMockData: {
                propsData: mockProps
            }
        });

        // Act
        const outputHtml = wrapper.html();

        // Assert
        expect(outputHtml).toEqual(expect.stringContaining(mockProps.buttonFooterCopy));
    });
    it('Should get 5 strings from getArrayOfListItemsFromRawCmsCopy when provided with a dashed (x5) buttonBodyCopy', async () => {
    // Arrange
        const { wrapper } = setupMocks({
            mountOptionsMockData: {
                propsData: mockProps
            }
        });
        // Act
        const results = wrapper.vm.getArrayOfListItemsFromRawCmsCopy(wrapper.vm.buttonBodyCopy);

        // Assert
        expect(results.length).toBe(5);
    });
    it('Should get strings from getArrayOfListItemsFromRawCmsCopy without dashes when provided with a dashed buttonBodyCopy', async () => {
    // Arrange
        const { wrapper } = setupMocks({
            mountOptionsMockData: {
                propsData: mockProps
            }
        });

        // Act
        const results = wrapper.vm.getArrayOfListItemsFromRawCmsCopy(wrapper.vm.buttonBodyCopy);

        // Assert
        const fileredResults = results.filter((result) => result.includes(' -'));
        expect(fileredResults.length).toBe(0);
    });
    it(
        'Should get 5 strings from getArrayOfListItemsFromRawCmsCopy when buttonBodyCopy has 6 total dashes, but one is empty ',
        async () => {
            // Arrange
            const moddedProps = mockProps;
            moddedProps.buttonBodyCopy = '- buttonBodyCopy test copy - 2 - 3 - 4 - 5 -';
            const { wrapper } = setupMocks({
                mountOptionsMockData: {
                    propsData: moddedProps
                }
            });

            // Act
            const results = wrapper.vm.getArrayOfListItemsFromRawCmsCopy(wrapper.vm.buttonBodyCopy);

            // Assert
            expect(results.length).toBe(5);
        }
    );
});
