<commit_before>import { Component } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { SprkAutocompleteInputContainerDirective } from './sprk-autocomplete-input-container.directive';

@Component({
  selector: 'sprk-test',
  template: `
    <div
      sprkAutocompleteInputContainer
      analyticsString="test"
      ariaLabelledby="test-label"
      idString="test-id"
    >
      <input
        id="autocomplete-input"
        name="autocomplete-input"
        type="text"
        class="sprk-b-TextInput--has-svg-icon sprk-u-Width-100"
        aria-describedby="autocomplete--error-container"
        aria-autocomplete="list"
        sprkInput
        idString="autocomplete-input1"
        autocomplete="off"
        autocapitalize="off"
        spellcheck="false"
      />
    </div>

    <div sprkAutocompleteInputContainer role="custom">
      <input
        id="autocomplete-input"
        name="autocomplete-input"
        type="text"
        class="sprk-b-TextInput--has-svg-icon sprk-u-Width-100"
        aria-describedby="autocomplete--error-container"
        aria-autocomplete="list"
        sprkInput
        idString="autocomplete-input1"
        autocomplete="off"
        autocapitalize="off"
        spellcheck="false"
      />
    </div>
  `,
})
class TestComponent {}

describe('Spark Autocomplete Input Container Directive', () => {
  let component: TestComponent;
  let fixture: ComponentFixture<TestComponent>;
  let element: HTMLElement;
  let element2: HTMLElement;

  beforeEach(async(() => {
    TestBed.configureTestingModule({
      declarations: [SprkAutocompleteInputContainerDirective, TestComponent],
    }).compileComponents();

    fixture = TestBed.createComponent(TestComponent);
    component = fixture.componentInstance;
    element = fixture.nativeElement.querySelectorAll('div')[0];
    element2 = fixture.nativeElement.querySelectorAll('div')[1];

    fixture.detectChanges();
  }));

  it('should create itself', () => {
    expect(component).toBeTruthy();
  });

  it('should add the correct base class', () => {
    expect(element.classList.toString()).toEqual(
      'sprk-b-TextInputIconContainer',
    );
  });

  it('should add a value for data-analytics if analyticsString has a value', () => {
    expect(element.getAttribute('data-analytics')).toEqual('test');
  });

  it('should add a value for data-id if idString has a value', () => {
    expect(element.getAttribute('data-id')).toEqual('test-id');
  });

  it('should not add a value for data-analytics if analyticsString has no value', () => {
    expect(element2.getAttribute('data-analytics')).toEqual(null);
  });

  it('should not add a value for data-id if idString has no value', () => {
    expect(element2.getAttribute('data-id')).toEqual(null);
  });

  it('should add role set to combobox', () => {
    expect(element.getAttribute('role')).toEqual('combobox');
  });

  it('should add role set to custom value if supplied', () => {
    expect(element2.getAttribute('role')).toEqual('custom');
  });

  it('should add aria-labelledby set to value from input', () => {
    expect(element.getAttribute('aria-labelledby')).toEqual('test-label');
  });

  it('should add aria-haspopup set to listbox', () => {
    expect(element.getAttribute('aria-haspopup')).toEqual('listbox');
  });
});
<commit_msg>add extra tests<commit_after>import { Component } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { SprkAutocompleteInputContainerDirective } from './sprk-autocomplete-input-container.directive';

@Component({
  selector: 'sprk-test',
  template: `
    <div
      sprkAutocompleteInputContainer
      analyticsString="test"
      ariaLabelledby="test-label"
      idString="test-id"
    >
      <input
        id="autocomplete-input"
        name="autocomplete-input"
        type="text"
        class="sprk-b-TextInput--has-svg-icon sprk-u-Width-100"
        aria-describedby="autocomplete--error-container"
        aria-autocomplete="list"
        sprkInput
        idString="autocomplete-input1"
        autocomplete="off"
        autocapitalize="off"
        spellcheck="false"
      />
    </div>

    <div sprkAutocompleteInputContainer role="custom" ariaHaspopup="custom">
      <input
        id="autocomplete-input"
        name="autocomplete-input"
        type="text"
        class="sprk-b-TextInput--has-svg-icon sprk-u-Width-100"
        aria-describedby="autocomplete--error-container"
        aria-autocomplete="list"
        sprkInput
        idString="autocomplete-input1"
        autocomplete="off"
        autocapitalize="off"
        spellcheck="false"
      />
    </div>
  `,
})
class TestComponent {}

describe('Spark Autocomplete Input Container Directive', () => {
  let component: TestComponent;
  let fixture: ComponentFixture<TestComponent>;
  let element: HTMLElement;
  let element2: HTMLElement;

  beforeEach(async(() => {
    TestBed.configureTestingModule({
      declarations: [SprkAutocompleteInputContainerDirective, TestComponent],
    }).compileComponents();

    fixture = TestBed.createComponent(TestComponent);
    component = fixture.componentInstance;
    element = fixture.nativeElement.querySelectorAll('div')[0];
    element2 = fixture.nativeElement.querySelectorAll('div')[1];

    fixture.detectChanges();
  }));

  it('should create itself', () => {
    expect(component).toBeTruthy();
  });

  it('should add the correct base class', () => {
    expect(element.classList.toString()).toEqual(
      'sprk-b-TextInputIconContainer',
    );
  });

  it('should add a value for data-analytics if analyticsString has a value', () => {
    expect(element.getAttribute('data-analytics')).toEqual('test');
  });

  it('should add a value for data-id if idString has a value', () => {
    expect(element.getAttribute('data-id')).toEqual('test-id');
  });

  it('should not add a value for data-analytics if analyticsString has no value', () => {
    expect(element2.getAttribute('data-analytics')).toEqual(null);
  });

  it('should not add a value for data-id if idString has no value', () => {
    expect(element2.getAttribute('data-id')).toEqual(null);
  });

  it('should add role set to combobox', () => {
    expect(element.getAttribute('role')).toEqual('combobox');
  });

  it('should add role set to custom value if supplied', () => {
    expect(element2.getAttribute('role')).toEqual('custom');
  });

  it('should add aria-labelledby set to value from input', () => {
    expect(element.getAttribute('aria-labelledby')).toEqual('test-label');
  });

  it('should not add aria-labelledby if no value is supplied', () => {
    expect(element2.getAttribute('aria-labelledby')).toEqual(null);
  });

  it('should add aria-haspopup set to listbox', () => {
    expect(element.getAttribute('aria-haspopup')).toEqual('listbox');
  });

  it('should use custom aria-haspopup value if supplied', () => {
    expect(element2.getAttribute('aria-haspopup')).toEqual('custom');
  });
});

{'fraction_non_alphanumeric': 0.1509995746490855, 'fraction_numerical': 0.004537076421380973, 'mean_word_length': 3.5627425614489003, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6967575', 'n_tokens_mistral': 2111, 'n_tokens_neox': 2102, 'n_words': 387}