import BmsButton from '@/components/button/BmsButton.vue';
import { mount, shallowMount } from '@vue/test-utils';

describe('BmsButton', () => {
  it('should mount component correctly', async () => {
    const wrapper = mount(BmsButton, {
      slots: {
        default: 'Hello world!',
      },
    } as any);

    expect(wrapper.text()).toContain('Hello world!');
  });

  describe('component tag behavior', () => {
    it('should be a correct link when to pass', () => {
      const wrapper = shallowMount(BmsButton, {
        props: {
          to: '/foo',
        },
      });

      expect(() => wrapper.get('button[type]')).toThrowError();
      expect(wrapper.find('router-link')).toBeTruthy();
    });

    it('should have type when its a button', () => {
      const wrapper = mount(BmsButton, {
        props: {
          submit: true,
        },
      });

      expect(wrapper.get('button[type="submit"]')).toBeTruthy();
    });
  });
});
