<commit_before>import {
  AsyncTestCompleter,
  beforeEach,
  beforeEachBindings,
  ddescribe,
  describe,
  expect,
  iit,
  flushMicrotasks,
  inject,
  it,
  xdescribe,
  TestComponentBuilder,
  xit,
} from 'angular2/test_lib';

import {bootstrap} from 'angular2/src/core/application';
import {Component, Directive, View} from 'angular2/metadata';
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {bind} from 'angular2/di';
import {DOCUMENT} from 'angular2/src/core/render/render';
import {RouteConfig, Route, Redirect} from 'angular2/src/router/route_config_decorator';
import {PromiseWrapper} from 'angular2/src/core/facade/async';
import {BaseException} from 'angular2/src/core/facade/lang';
import {
  ROUTER_BINDINGS,
  RouteParams,
  Router,
  APP_BASE_HREF,
  ROUTER_DIRECTIVES,
  HashLocationStrategy
} from 'angular2/router';

import {LocationStrategy} from 'angular2/src/router/location_strategy';
import {MockLocationStrategy} from 'angular2/src/mock/mock_location_strategy';
import {APP_COMPONENT} from 'angular2/src/core/application_tokens';

export function main() {
  describe('router injectables', () => {
    beforeEachBindings(
        () => { return [ROUTER_BINDINGS, bind(LocationStrategy).toClass(MockLocationStrategy)]; });

    // do not refactor out the `bootstrap` functionality. We still want to
    // keep this test around so we can ensure that bootstrapping a router works
    describe('boostrap functionality', () => {
      it('should bootstrap a simple app', inject([AsyncTestCompleter], (async) => {
           var fakeDoc = DOM.createHtmlDocument();
           var el = DOM.createElement('app-cmp', fakeDoc);
           DOM.appendChild(fakeDoc.body, el);

           bootstrap(AppCmp,
                     [
                       ROUTER_BINDINGS,
                       bind(LocationStrategy).toClass(MockLocationStrategy),
                       bind(DOCUMENT).toValue(fakeDoc)
                     ])
               .then((applicationRef) => {
                 var router = applicationRef.hostComponent.router;
                 router.subscribe((_) => {
                   expect(el).toHaveText('outer { hello }');
                   expect(applicationRef.hostComponent.location.path()).toEqual('');
                   async.done();
                 });
               });
         }), 1000);
    });

    describe('broken app', () => {
      beforeEachBindings(() => { return [bind(APP_COMPONENT).toValue(BrokenAppCmp)]; });

      it('should rethrow exceptions from component constructors',
         inject([AsyncTestCompleter, TestComponentBuilder], (async, tcb: TestComponentBuilder) => {
           tcb.createAsync(AppCmp).then((rootTC) => {
             var router = rootTC.componentInstance.router;
             PromiseWrapper.catchError(router.navigate('/cause-error'), (error) => {
               expect(rootTC.nativeElement).toHaveText('outer { oh no }');<commit_msg>test(router): fix typo in spec name<commit_after>import {
  AsyncTestCompleter,
  beforeEach,
  beforeEachBindings,
  ddescribe,
  describe,
  expect,
  iit,
  flushMicrotasks,
  inject,
  it,
  xdescribe,
  TestComponentBuilder,
  xit,
} from 'angular2/test_lib';

import {bootstrap} from 'angular2/src/core/application';
import {Component, Directive, View} from 'angular2/metadata';
import {DOM} from 'angular2/src/core/dom/dom_adapter';
import {bind} from 'angular2/di';
import {DOCUMENT} from 'angular2/src/core/render/render';
import {RouteConfig, Route, Redirect} from 'angular2/src/router/route_config_decorator';
import {PromiseWrapper} from 'angular2/src/core/facade/async';
import {BaseException} from 'angular2/src/core/facade/lang';
import {
  ROUTER_BINDINGS,
  RouteParams,
  Router,
  APP_BASE_HREF,
  ROUTER_DIRECTIVES,
  HashLocationStrategy
} from 'angular2/router';

import {LocationStrategy} from 'angular2/src/router/location_strategy';
import {MockLocationStrategy} from 'angular2/src/mock/mock_location_strategy';
import {APP_COMPONENT} from 'angular2/src/core/application_tokens';

export function main() {
  describe('router injectables', () => {
    beforeEachBindings(
        () => { return [ROUTER_BINDINGS, bind(LocationStrategy).toClass(MockLocationStrategy)]; });

    // do not refactor out the `bootstrap` functionality. We still want to
    // keep this test around so we can ensure that bootstrapping a router works
    describe('bootstrap functionality', () => {
      it('should bootstrap a simple app', inject([AsyncTestCompleter], (async) => {
           var fakeDoc = DOM.createHtmlDocument();
           var el = DOM.createElement('app-cmp', fakeDoc);
           DOM.appendChild(fakeDoc.body, el);

           bootstrap(AppCmp,
                     [
                       ROUTER_BINDINGS,
                       bind(LocationStrategy).toClass(MockLocationStrategy),
                       bind(DOCUMENT).toValue(fakeDoc)
                     ])
               .then((applicationRef) => {
                 var router = applicationRef.hostComponent.router;
                 router.subscribe((_) => {
                   expect(el).toHaveText('outer { hello }');
                   expect(applicationRef.hostComponent.location.path()).toEqual('');
                   async.done();
                 });
               });
         }), 1000);
    });

    describe('broken app', () => {
      beforeEachBindings(() => { return [bind(APP_COMPONENT).toValue(BrokenAppCmp)]; });

      it('should rethrow exceptions from component constructors',
         inject([AsyncTestCompleter, TestComponentBuilder], (async, tcb: TestComponentBuilder) => {
           tcb.createAsync(AppCmp).then((rootTC) => {
             var router = rootTC.componentInstance.router;
             PromiseWrapper.catchError(router.navigate('/cause-error'), (error) => {
               expect(rootTC.nativeElement).toHaveText('outer { oh no }');
{'fraction_non_alphanumeric': 0.12357640659527452, 'fraction_numerical': 0.005779364269930308, 'mean_word_length': 2.9596231493943472, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, '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': '6079160', 'n_tokens_mistral': 1695, 'n_tokens_neox': 1636, 'n_words': 331}