<commit_before>import {
  iit,
  it,
  ddescribe,
  describe,
  expect,
  inject,
  injectAsync,
  TestComponentBuilder,
} from 'angular2/testing';

import {Component} from 'angular2/angular2';

import {NgbCollapse} from './collapse';

function getCollapsibleContent(element: Element): Element {
  return element.querySelector('.collapse');
}

function getButton(element) {
  return element.querySelector('button');
}

describe('ngb-collapse', () => {
  let html: string;

  beforeEach(() => {
    html = `
      <button type="button" (click)="collapsed = !collapsed">Toggle collapse</button>
      <div [ngb-collapse]="collapsed">
        <div class="card">
          <div class="card-block">
            Some content
          </div>
        </div>
      </div>
    `;
  });

  it('should have content open and aria-expanded true', injectAsync([TestComponentBuilder], (tcb) => {
       return tcb.overrideTemplate(TestComponent, html).createAsync(TestComponent).then((fixture) => {
         fixture.detectChanges();

         const compiled = fixture.debugElement.nativeElement;

         const content = getCollapsibleContent(compiled);

         expect(content).toHaveCssClass('in');
         expect(content.getAttribute('aria-expanded')).toBe('true');
       });
     }));

  it('should have content closed and aria-expanded false', injectAsync([TestComponentBuilder], (tcb) => {
       return tcb.overrideTemplate(TestComponent, html).createAsync(TestComponent).then((fixture) => {
         const tc = fixture.debugElement.componentInstance;
         tc.collapsed = true;
         fixture.detectChanges();

         const compiled = fixture.debugElement.nativeElement;

         const content = getCollapsibleContent(compiled);

         expect(content).not.toHaveCssClass('in');
         expect(content.getAttribute('aria-expanded')).toBe('false');
       });
     }));

  it('should toggle collapsed content on click', injectAsync([TestComponentBuilder], (tcb) => {
       return tcb.overrideTemplate(TestComponent, html).createAsync(TestComponent).then((fixture) => {
         fixture.detectChanges();
         const compiled = fixture.debugElement.nativeElement;
         const content = getCollapsibleContent(compiled);
         expect(content).toHaveCssClass('in');

         const buttonEl = getButton(compiled);

         buttonEl.click();
         fixture.detectChanges();
         expect(content).not.toHaveCssClass('in');

         buttonEl.click();
         fixture.detectChanges();
         expect(content).toHaveCssClass('in');
       });
     }));
});

@Component({selector: 'test-cmp', directives: [NgbCollapse], template: ''})
class TestComponent {
  collapsed = false;
}
<commit_msg>test(collapse): tests simplications<commit_after>import {
  iit,
  it,
  ddescribe,
  describe,
  expect,
  inject,
  injectAsync,
  TestComponentBuilder,
} from 'angular2/testing';

import {Component} from 'angular2/angular2';

import {NgbCollapse} from './collapse';

function getCollapsibleContent(element: Element): Element {
  return element.querySelector('.collapse');
}

describe('ngb-collapse', () => {

  const html = `<div [ngb-collapse]="collapsed">Some content</div>`;

  it('should have content open and aria-expanded true', injectAsync([TestComponentBuilder], (tcb) => {
       return tcb.overrideTemplate(TestComponent, html).createAsync(TestComponent).then((fixture) => {
         fixture.detectChanges();

         const compiled = fixture.debugElement.nativeElement;

         const content = getCollapsibleContent(compiled);

         expect(content).toHaveCssClass('in');
         expect(content.getAttribute('aria-expanded')).toBe('true');
       });
     }));

  it('should have content closed and aria-expanded false', injectAsync([TestComponentBuilder], (tcb) => {
       return tcb.overrideTemplate(TestComponent, html).createAsync(TestComponent).then((fixture) => {
         const tc = fixture.debugElement.componentInstance;
         tc.collapsed = true;
         fixture.detectChanges();

         const compiled = fixture.debugElement.nativeElement;

         const content = getCollapsibleContent(compiled);

         expect(content).not.toHaveCssClass('in');
         expect(content.getAttribute('aria-expanded')).toBe('false');
       });
     }));

  it('should toggle collapsed content based on bound model change', injectAsync([TestComponentBuilder], (tcb) => {
       return tcb.overrideTemplate(TestComponent, html).createAsync(TestComponent).then((fixture) => {
         fixture.detectChanges();
         const compiled = fixture.debugElement.nativeElement;
         const content = getCollapsibleContent(compiled);
         expect(content).toHaveCssClass('in');

         fixture.debugElement.componentInstance.collapsed = true;
         fixture.detectChanges();
         expect(content).not.toHaveCssClass('in');

         fixture.debugElement.componentInstance.collapsed = false;
         fixture.detectChanges();
         expect(content).toHaveCssClass('in');
       });
     }));
});

@Component({selector: 'test-cmp', directives: [NgbCollapse], template: ''})
class TestComponent {
  collapsed = false;
}

{'fraction_non_alphanumeric': 0.13809154383242825, 'fraction_numerical': 0.0011636927851047323, 'mean_word_length': 3.507867132867133, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 28, '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': '4912965', 'n_tokens_mistral': 1415, 'n_tokens_neox': 1410, 'n_words': 254}