import { getButtonOrLink } from '../getButtonOrLink';
describe('rootTag', () => {
  it('returns <a> when href prop exists', () => {
    const component = { href: '#' };
    const { rootTag } = getButtonOrLink(component, 'button');
    expect(rootTag).toBe('a');
  });
  it('returns <button> when onclick exists on hostEl attributes', () => {
    const component = { hostEl: { getAttribute: key => key === 'onclick' } };
    const { rootTag } = getButtonOrLink(component, 'a');
    expect(rootTag).toBe('button');
  });
  it('returns <a> when both href and onclick exist', () => {
    const component = {
      href: '#',
      hostEl: { attributes: { onclick: Function } }
    };
    const { rootTag } = getButtonOrLink(component, 'span');
    expect(rootTag).toBe('a');
  });
  it('returns given defaultTag when href and onclick do not exist', () => {
    const component = {};
    const { rootTag } = getButtonOrLink(component, 'span');
    expect(rootTag).toBe('span');
  });
});
describe('buttonOrLinkAttrs', () => {
  it('sets <button> "type" to "button" by default', () => {
    const component = {};
    const { buttonOrLinkAttrs } = getButtonOrLink(component, 'button');
    expect(buttonOrLinkAttrs.type).toBe('button');
  });
  it('sets <button> "type" to given value', () => {
    const component = { type: 'submit' };
    const { buttonOrLinkAttrs } = getButtonOrLink(component, 'button');
    expect(buttonOrLinkAttrs.type).toBe('submit');
  });
  it('sets <button> "disabled" to undefined by default', () => {
    const component = {};
    const { buttonOrLinkAttrs } = getButtonOrLink(component, 'button');
    expect(buttonOrLinkAttrs.disabled).toBeUndefined();
  });
  it('sets <button> "disabled" to given value', () => {
    const component = { disabled: true };
    const { buttonOrLinkAttrs } = getButtonOrLink(component, 'button');
    expect(buttonOrLinkAttrs.disabled).toBe(true);
  });
  it('properly disables <a> tag', () => {
    const component = { disabled: true };
    const { buttonOrLinkAttrs } = getButtonOrLink(component, 'a');
    expect(buttonOrLinkAttrs.disabled).toBeUndefined();
    expect(buttonOrLinkAttrs['aria-disabled']).toBe('true');
    expect(buttonOrLinkAttrs.tabindex).toBe(-1);
  });
});
//# sourceMappingURL=getButtonOrLink.spec.js.map
