<commit_before>import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { UIToggleModule } from './index';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { Component, DebugElement } from '@angular/core';
import { By } from '@angular/platform-browser';
describe('UIToggle', () => {

    let fixture: ComponentFixture<any>;


    function createEvent(type: string):Event {
        return new Event(type, {bubbles: true, cancelable: true});
    }

    beforeEach(async(() => {
        TestBed.configureTestingModule({
            imports: [UIToggleModule, FormsModule, ReactiveFormsModule],
            declarations: [
                NgModelBasic
            ]
        });

        TestBed.compileComponents();
    }));

    describe('ngModel basic', () => {
        let toggleDebugElement: DebugElement;
        let toggleNativeElement: HTMLElement;
        let toggleInstance: NgModelBasic;

        beforeEach(() => {
            fixture = TestBed.createComponent(NgModelBasic);
            fixture.detectChanges();

            toggleDebugElement = fixture.debugElement.query(By.directive(NgModelBasic));
            toggleNativeElement = toggleDebugElement.nativeElement;
            toggleInstance = toggleDebugElement.componentInstance;
        });

        it('should change value of NgModelBasic by clicking the UIToggle', () => {
            expect(toggleInstance.value).toBe(true);
            toggleNativeElement.dispatchEvent(createEvent('click'));
            fixture.detectChanges();
            expect(toggleInstance.value).toBe(false);
        });
    });
});

@Component({
    template: `<ui-toggle [(ngModel)]="value"></ui-toggle>`
})
class NgModelBasic {
    value = false;<commit_msg>fix bug in test spec<commit_after>import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { UIToggleModule } from './index';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { Component, DebugElement } from '@angular/core';
import { UIToggle } from './toggle';
import { By } from '@angular/platform-browser';
describe('UIToggle', () => {

    let fixture: ComponentFixture<any>;


    function createEvent(type: string): Event {
        return new Event(type, {bubbles: true, cancelable: true});
    }

    beforeEach(async(() => {
        TestBed.configureTestingModule({
            imports: [UIToggleModule, FormsModule, ReactiveFormsModule],
            declarations: [
                NgModelBasic
            ]
        });

        TestBed.compileComponents();
    }));

    describe('ngModel basic', () => {
        let testDebugElement: DebugElement;
        let testNativeElement: HTMLElement;
        let testInstance: NgModelBasic;
        let labelElement: HTMLLabelElement;

        beforeEach(() => {
            fixture = TestBed.createComponent(NgModelBasic);
            fixture.detectChanges();

            testDebugElement = fixture.debugElement;
            testNativeElement = testDebugElement.nativeElement;
            testInstance = testDebugElement.componentInstance;
            labelElement = testNativeElement.querySelector('label');
        });

        it('should change value of NgModelBasic by clicking the UIToggle', async() => {
            expect(testInstance.value).toBe(false);
            labelElement.click();
            fixture.detectChanges();
            fixture.whenStable()
                .then(() => {
                    expect(testInstance.value).toBe(true);
                });
        });
    });
});

@Component({
    template: `
        <form>
            <ui-toggle [(ngModel)]="value" name="toggle1"></ui-toggle>
        </form>`
})
class NgModelBasic {
    value = false;
{'fraction_non_alphanumeric': 0.12459807073954984, 'fraction_numerical': 0.0002679528403001072, 'mean_word_length': 2.6348588120740017, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 22, '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': '2852375', 'n_tokens_mistral': 977, 'n_tokens_neox': 945, 'n_words': 197}