import { shallowMount } from '@vue/test-utils';
import serviceZipQuestion from '@/layouts/schedule-page/service-location/service-zip-question/service-zip-question.vue';

describe('service-zip-question.vue', () => {
    it('Should get the modelValue', async () => {
        // Arrange
        const text = '12345';
        const wrapper = shallowMount(serviceZipQuestion, {
            props: {
                modelValue: text
            },
            attachTo: document.body
        });

        // Act
        const modelValueText = wrapper.vm.internalZipcode;
        wrapper.vm.internalZipcode = '55555';

        // Assert
        expect(modelValueText).toEqual('12345');
    });

    it('Should emit to set value', async () => {
        // Arrange
        const text = '12345';
        const wrapper = shallowMount(serviceZipQuestion, {
            props: {
                modelValue: text
            },
            attachTo: document.body
        });

        // Act
        wrapper.vm.internalZipcode = '55555';
        wrapper.vm.updateModelValue();

        // Assert
        expect(wrapper.emitted('update:modelValue')).toEqual([['55555']]);
    });
});
