import { shallowMount } from '@vue/test-utils';
import deductibleBox from '@/layouts/tpa-submit/deductible-box/deductible-box.vue';

describe('deductible-box', () => {
    let wrapper;
    const defaultValue = '1820';

    beforeEach(() => {
        wrapper = shallowMount(deductibleBox, {
            propsData: { value: defaultValue }
        });
    });

    it('renders the correct deductible value', () => {
        const valueElement = wrapper.find('#deductibleValue');
        expect(valueElement.text()).toBe(defaultValue);
    });

    it('renders the correct deductible label', () => {
        const labelElement = wrapper.find('#deductibleLabel');
        expect(labelElement.text()).toBe('Deductible:');
    });

    it('has the correct id', () => {
        expect(wrapper.attributes().id).toBe('deductibleBox');
    });

    it('has the correct classes', () => {
        expect(wrapper.classes().length).toBe(1);
        expect(wrapper.classes()).toContain('deductible-box');
    });
    it.each([
        ['', ''],
        [null, ''],
        [undefined, '']
    ])('renders correctly with value "%p"', (value, expected) => {
        wrapper = shallowMount(deductibleBox, {
            propsData: { value }
        });
        const valueElement = wrapper.find('#deductibleValue');
        expect(valueElement.text()).toBe(expected);
    });

    it('renders correctly with a very long value', () => {
        const longValue = '1'.repeat(1000);
        wrapper = shallowMount(deductibleBox, {
            propsData: {
                value: longValue
            }
        });
        const valueElement = wrapper.find('#deductibleValue');
        expect(valueElement.text()).toBe(longValue);
    });

    it('renders correctly with special characters', () => {
        const specialValue = '!@#$%^&*()';
        wrapper = shallowMount(deductibleBox, {
            propsData: {
                value: specialValue
            }
        });
        const valueElement = wrapper.find('#deductibleValue');
        expect(valueElement.text()).toBe(specialValue);
    });
});
