<commit_before>import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { ReactiveFormsModule, FormsModule } from '@angular/forms';

import { CreateCodeComponent } from './create.component';

describe('CreateCodeComponent', () =>
{
  let component: CreateCodeComponent;
  let fixture: ComponentFixture<CreateCodeComponent>;

  beforeEach(async(() =>
  {
    TestBed.configureTestingModule({
      imports: [ReactiveFormsModule, FormsModule, HttpClientTestingModule, RouterTestingModule],
      declarations: [CreateCodeComponent]
    })
      .compileComponents();
  }));

  beforeEach(() =>
  {
    fixture = TestBed.createComponent(CreateCodeComponent);
    component = fixture.componentInstance;
    component.ngOnInit();
    fixture.detectChanges();
  });

  it('should create', () =>
  {
    expect(component).toBeTruthy();
  });
});<commit_msg>Written Unit Test for Code example create<commit_after>import { async, ComponentFixture, TestBed, tick, fakeAsync } from '@angular/core/testing';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { ReactiveFormsModule, FormsModule } from '@angular/forms';
import { Router } from '@angular/router';
import { Location } from '@angular/common';

import { CreateCodeComponent } from './create.component';
import { ViewCodeComponent } from '../view/view.component';

describe('CreateCodeComponent', () =>
{
  let component: CreateCodeComponent;
  let fixture: ComponentFixture<CreateCodeComponent>;
  let router: Router;
  let location: Location;

  beforeEach(async(() =>
  {
    TestBed.configureTestingModule({
      imports: [ReactiveFormsModule, FormsModule, HttpClientTestingModule,
                RouterTestingModule.withRoutes([
                  { path: 'code-example/view', component: ViewCodeComponent },
                ])],
      declarations: [CreateCodeComponent]
    })
      .compileComponents();
    router = TestBed.inject(Router);
    location = TestBed.inject(Location);
    router.initialNavigation();
  }));

  beforeEach(() =>
  {
    fixture = TestBed.createComponent(CreateCodeComponent);
    component = fixture.componentInstance;
    component.ngOnInit();
    fixture.detectChanges();
  });

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

  it('should valid submit', () =>
  {
    component.validSubmit();
    expect(component.isSubmitted).toBeTruthy();
  });

  it('should create CodeExample Item', fakeAsync(() =>
  {
    component.createCodeExampleItem();
    expect(component.isSubmitted ).toBeTruthy();
    expect(component.codeExampleForm.valid).toBeFalsy();

    router.navigate(['code-example/view']);
    tick();
    expect(location.path()).toBe('/code-example/view');
  }));
});
{'fraction_non_alphanumeric': 0.14144848690921455, 'fraction_numerical': 0.0, 'mean_word_length': 4.368613138686132, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '5629136', 'n_tokens_mistral': 818, 'n_tokens_neox': 799, 'n_words': 152}