diff --git a/public/docs/ts/latest/guide/testing.jade b/public/docs/ts/latest/guide/testing.jade index 58ad193878..1101187b7b 100644 --- a/public/docs/ts/latest/guide/testing.jade +++ b/public/docs/ts/latest/guide/testing.jade @@ -53,7 +53,7 @@ block includes 1. [A simple component test](#simple-component-test) - 1. [一个简单的组件测试](#simple-component-test) + 1. [简单的组件测试](#simple-component-test) - [_configureTestingModule_](#configure-testing-module) @@ -154,7 +154,7 @@ block includes 1. [Test a routed component with parameters](#routed-component-w-param) - 1. [测试一个带有路由和路由参数的组件](#routed-component-w-param) + 1. [测试带有路由和路由参数的组件](#routed-component-w-param) - [_Observable_ test double](#stub-observable) @@ -177,7 +177,7 @@ block includes 1. [Test a _RouterOutlet_ component](#router-outlet-component) - 1. [测试一个**RouterOutlet**组件](#router-outlet-component) + 1. [测试带有**RouterOutlet**组件](#router-outlet-component) - [stubbing unneeded components](#stub-component) @@ -322,7 +322,7 @@ table(width="100%") It ships with an HTML test runner that executes tests in the browser. [Jasmine测试框架](http://jasmine.github.io/2.4/introduction.html)提供了所有编写基本测试的工具。 - 它自带一个HTML测试运行器,用来在浏览器中执行测试。 + 它自带HTML测试运行器,用来在浏览器中执行测试。 tr(style=top) td(style="vertical-align: top") Angular测试工具 @@ -333,7 +333,7 @@ table(width="100%") Use them to condition and control parts of the application as they interact _within_ the Angular environment. - Angular测试工具为被测试的Angular应用代码创建一个测试环境。在应用代码与Angular环境互动时,使用Angular测试工具来限制和控制应用的部分代码。 + Angular测试工具为被测试的Angular应用代码创建测试环境。在应用代码与Angular环境互动时,使用Angular测试工具来限制和控制应用的部分代码。 tr(style=top) td(style="vertical-align: top") Karma @@ -385,12 +385,12 @@ table(width="100%") 1. Start a new project following the instructions in the [QuickStart github repository](https://github.com/angular/quickstart/blob/master/README.md). - 1. 根据[快速起步的github库](https://github.com/angular/quickstart/blob/master/README.md)中的说明创建一个新的项目. + 1. 根据[快速起步的github库](https://github.com/angular/quickstart/blob/master/README.md)中的说明创建新的项目. 1. Start a new project with the [Angular CLI](https://github.com/angular/angular-cli/blob/master/README.md). - 1. 使用[Angular CLI](https://github.com/angular/angular-cli/blob/master/README.md)创建一个新的项目。 + 1. 使用[Angular CLI](https://github.com/angular/angular-cli/blob/master/README.md)创建新的项目。 Both approaches install **npm packages, files, and scripts** pre-configured for applications built in their respective modalities. @@ -508,11 +508,11 @@ table(width="100%") Start with a simple test to make sure the setup works properly. - 编写一个简单的测试,来确认以上的配置是否工作正常。 + 编写简单的测试,来确认以上的配置是否工作正常。 Create a new file called `1st.spec.ts` in the application root folder, `app/` - 在应用的根目录`app/`创建一个新文件,名叫`1st.spec.ts`。 + 在应用的根目录`app/`创建新文件,名叫`1st.spec.ts`。 .alert.is-important :marked @@ -655,7 +655,7 @@ code-example(format="." language="bash"). - Set a breakpoint in the test - - 在测试中设置一个断点。 + - 在测试中设置断点。 - Refresh the browser … and it stops at the breakpoint. @@ -698,7 +698,7 @@ a(href="#top").to-top 回到顶部 then probes the test instance API surface. [孤立的单元测试](#isolated-unit-tests "不使用Angular测试工具进行单元测试")独立自己检测类的实例,不依靠Angular或者任何其他注入值。 - 测试器使用`new`创建一个类的测试实例,在需要时提供用于测试的构造函数参数复制品,并测试被测试实例的API。 + 测试器使用`new`创建类的测试实例,在需要时提供用于测试的构造函数参数复制品,并测试被测试实例的API。 You can and should write isolated unit tests for pipes and services. @@ -727,8 +727,8 @@ a(href="#top").to-top 回到顶部 that you configure to produce the module environment for the class you want to test. You tell the `TestBed` to create an instance of the _component-under-test_ and probe that instance with tests. - `TestBed`创建一个Angular测试模块 - 一个`@NgModule`类 - 通过配置它,你为想要测试的类创造模块环境。 - 通过`TestBed`创建一个被测试的组件的实例,并使用测试来测探这个实例。 + `TestBed`创建Angular测试模块 - `@NgModule`类 - 通过配置它,你为想要测试的类创造模块环境。 + 通过`TestBed`创建被测试的组件的实例,并使用测试来测探这个实例。 Before each spec, the `TestBed` resets itself to a base state. The base state includes a default testing module configuration consisting of the @@ -750,14 +750,14 @@ a(href="#top").to-top 回到顶部 to fit your application tests. Optional `override...` methods can fine-tune aspects of the configuration. - 默认配置只是测试一个应用的**基础**。 - 使用一个定义额外inports、declarations、providers和schemas的对象来调用`TestBed.configureTestingModule`,以适合你的应用程序的测试。 + 默认配置只是测试应用的**基础**。 + 使用定义额外imports、declarations、providers和schemas的对象来调用`TestBed.configureTestingModule`,以适合你的应用程序的测试。 可选的`override...`方法可以微调配置的各个方面。 After configuring the `TestBed`, tell it to create an instance of the _component-under-test_ and the test fixture that you'll need to inspect and control the component's immediate environment. - `TestBed`配置完成以后,用它创建一个**被测试的组件**的实例和测试fixture,用来检查和控制组件周围的环境。 + `TestBed`配置完成以后,用它创建**被测试的组件**的实例和测试fixture,用来检查和控制组件周围的环境。 +makeExample('testing/ts/app/banner.component.spec.ts', 'simple-example-before-each', 'app/banner.component.spec.ts (simplified)')(format='.') :marked @@ -773,7 +773,7 @@ a(href="#top").to-top 回到顶部 Let's dive right into Angular testing, starting with with the components of a sample application. 完整的关于Angular测试工具的回顾将会在[本章后面](#atu-apis)出现。 - 让我们深入到Angular测试,以一个例子应用的组件开始。 + 让我们深入到Angular测试,以例子应用的组件开始。 a(href="#top").to-top Back to top a(href="#top").to-top 回到顶部 @@ -788,7 +788,7 @@ a(href="#top").to-top 回到顶部 This chapter tests a cut-down version of the _Tour of Heroes_ [tutorial app](../tutorial). - 本章测试一个**简化**版本的**英雄指南**[教程应用程序](../tutorial)。 + 本章测试**简化**版本的**英雄指南**[教程应用程序](../tutorial)。 The following live example shows how it works and provides the complete source code. @@ -818,7 +818,7 @@ a(href="#top").to-top 回到顶部 :marked # Test a component - # 测试一个组件 + # 测试组件 :marked The top of the screen displays application title, presented by the `BannerComponent` in `app/banner.component.ts`. @@ -856,7 +856,7 @@ a(href="#top").to-top 回到顶部 `TestBed.configureTestingModule` takes an `@NgModule`-like metadata object. This one simply declares the component to test, `BannerComponent`. - `TestBed.configureTestingModule`接受一个像`@NgModule`元素据的对象。 + `TestBed.configureTestingModule`接受像`@NgModule`元素据的对象。 这里的对象仅仅声明了要测试的组件`BannerComponent`。 It lacks `imports` because (a) it extends the default testing module configuration which @@ -873,14 +873,14 @@ a(href="#top").to-top 回到顶部 `TestBed.createComponent` creates an instance of `BannerComponent` to test and returns a [fixture](#component-fixture). - `TestBed.createComponent`创建一个`BannerComponent`组件的实例用来测试和返回一个[fixture](#component-fixture)。 + `TestBed.createComponent`创建`BannerComponent`组件的实例用来测试和返回[fixture](#component-fixture)。 `TestBed.createComponent` closes the current `TestBed` instance to further configuration. You cannot call any more `TestBed` configuration methods, not `configureTestModule` nor any of the `override...` methods. The `TestBed` throws an error if you try. `TestBed.createComponent`关闭当前`TestBed`实例,让它不能再被配置。 - 你不能再调用`TestBed`的配置方法,也不能调用`configureTestingModule`或者任何`override...`方法,否则`TestBed`会抛出一个错误。 + 你不能再调用`TestBed`的配置方法,也不能调用`configureTestingModule`或者任何`override...`方法,否则`TestBed`会抛出错误。 .alert.is-important :marked @@ -895,7 +895,7 @@ a(href="#top").to-top 回到顶部 The fixture provides access to the component instance itself and to the **`DebugElement`** which is a handle on the component's DOM element. - `createComponent`方法返回一个**`ComponentFixture`**,用来控制和访问已创建的组件所在的测试环境。 + `createComponent`方法返回**`ComponentFixture`**,用来控制和访问已创建的组件所在的测试环境。 这个fixture提供了对组件实例自身的访问,同时还提供了用来访问组件的DOM元素的**`DebugElement`**对象。 The `title` property value was interpolated into the DOM within `