import FieldComponent from '@/plugins/field/FieldComponent.vue';
import { mount, shallowMount } from '@vue/test-utils';
import { BmsCaption } from '@/index';
import { nextTick } from 'vue';

describe('FieldComponent', () => {
  it('should display label', async () => {
    const wrapper = mount(FieldComponent, {
      slots: {
        default: '<input type="text" />',
      },
      props: {
        label: 'Set a value',
      },
    } as any);

    expect(wrapper.text()).toContain('Set a value');
  });

  it('should display errors', async () => {
    const wrapper = mount(FieldComponent, {
      slots: {
        default: '<input type="text" />',
      },
      props: {
        errors: ['An error on the field', 'Seconds Errors'],
      },
    } as any);

    const bmsCaptions = wrapper.findAllComponents(BmsCaption);
    expect(bmsCaptions.length).toBe(2);
    expect(bmsCaptions[0].html()).toContain('An error on the field');
    expect(bmsCaptions[1].html()).toContain('Seconds Errors');
  });
});
