Skip to content

Commit

Permalink
Keep up-to-date and translate testing guides.
Browse files Browse the repository at this point in the history
  • Loading branch information
towerhe committed Jul 23, 2014
1 parent 45282f0 commit fea6d5c
Show file tree
Hide file tree
Showing 48 changed files with 4,135 additions and 299 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.0-p247
2.1.1
33 changes: 33 additions & 0 deletions data/guides.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,35 @@
- title: "介绍"
url: "enumerables"
测试:
- title: "介绍"
url: "testing"
- title: "集成测试"
url: "testing/integration"
- title: "测试助手"
url: "testing/test-helpers"
- title: "测试用户交互"
url: "testing/testing-user-interaction"
- title: "单元测试"
url: "testing/unit"
- title: "单元测试基础"
url: "testing/unit-testing-basics"
- title: "测试组件"
url: "testing/testing-components"
# - title: "Testing Handlebars Helpers"
# url: "testing/testing-handlebars-helpers"
- title: "测试控制器"
url: "testing/testing-controllers"
- title: "测试路由"
url: "testing/testing-routes"
# - title: "Testing Views"
# url: "testing/testing-views"
- title: "测试模型"
url: "testing/testing-models"
# - title: "Testing XHR"
# url: "testing/testing-xhr"
- title: "自动化测试"
url: "testing/test-runners"

配置Ember.js:
- title: "禁用基本类型扩展"
url: "configuring-ember/disabling-prototype-extensions"
Expand Down Expand Up @@ -328,6 +355,12 @@ Cookbook:
- title: "创建可以重用的社交分享按钮"
url: "cookbook/helpers_and_components/creating_reusable_social_share_buttons"
skip_sidebar_item: true
- title: "异步操作的旋转按钮"
url: "cookbook/helpers_and_components/spin_button_for_asynchronous_actions"
skip_sidebar_item: true
- title: "添加Google Analytics跟踪"
url: "cookbook/helpers_and_components/adding_google_analytics_tracking"
skip_sidebar_item: true
# objects
- title: "使用对象"
url: "cookbook/working_with_objects"
Expand Down
4 changes: 2 additions & 2 deletions source/bilingual_guides/concepts/naming-conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ your entire application shares a single instance of each controller.

## 简单的路由(Simple Routes)

Each of your routes will have a controller and a template with the
+same name as the route.
Each of your routes will have a controller, and a template with the
same name as the route.

对于应用中的每一个路由,都会有以路由名称命名的控制器和模板。

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,4 @@ This example shows:
1. 将通用模态对话框标记和操作包裹到一个组件中。
1. 处理叠加层被点击的事件,来关闭模态对话框 。

<a class="jsbin-embed" href="http://emberjs.jsbin.com/lokozegi/4/embed?output">JS Bin</a>
<a class="jsbin-embed" href="http://emberjs.jsbin.com/lokozegi/110/embed">JS Bin</a>
2 changes: 1 addition & 1 deletion source/bilingual_guides/getting-ember/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Adding Ember to your application with Bower is easy simply run `bower install em
{
"name": "your-app",
"dependencies": {
"ember": "~1.2",
"ember": "~1.5",
"ember-data": "~1.0.0-beta.4"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ Inside `js/application.js` add the following code:
window.Todos = Ember.Application.create();
```

This will create a new instance of `Ember.Application` and make it available as a variable within your browser's JavaScript environment.
This will create a new instance of `Ember.Application` and make it available as a variable named `Todos` within your browser's JavaScript environment.

这会创建一个 `Ember.Application` 的实例,并将它作为你本地浏览器JavaScript环境的一个变量供使用
这会创建一个 `Ember.Application` 的实例,并将它作为你本地浏览器JavaScript环境的一个名为`Todos`的变量供使用

Inside `js/router.js` add the following code:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ var tom = App.Person.create({
name: "Tom Dale"
});

tom.helloWorld(); // alerts "Hi my name is Tom Dale"
tom.helloWorld(); // alerts "Hi, my name is Tom Dale"
```

For performance reasons, note that you cannot redefine an instance's
Expand Down
36 changes: 36 additions & 0 deletions source/bilingual_guides/routing/defining-your-routes.md
Original file line number Diff line number Diff line change
Expand Up @@ -538,3 +538,39 @@ Remember, these routes are part of every application, so you don't need
to specify them in `App.Router.map`.

请记住,这些路由是每个应用的一部分,因此不需要在`App.Router.map`中指定。

### Wildcard / globbing routes

### 通配符路由

You can define wildcard routes that will match mutliple routes. This could be used, for example,
if you'd like a catchall route which is useful when the user enters an incorrect URL not managed
by your app.

可以定义通配符路由来匹配多个路由。这种方法很有用,比如如果想获取用户进入应用的错误路由的时候。

```javascript
App.Router.map(function() {
this.route('catchall', {path: '/*wildcard'});
});
```

Like all routes with a dynamic segment, you must provide a context when using a `{{link-to}}`
or `transitionTo` to programatically enter this route.

通配符路由与动态路由一样,在使用`{{link-to}}或者`transitionTo`来进入这个路由的时候,需要提供一个上下文。

```javascript
App.ApplicationRoute = Ember.Route.extend({
actions: {
error: function () {
this.transitionTo('catchall', "application-error");
}
}
});
```

With this code, if an error bubbles up to the Application route, your application will enter
the `catchall` route and display `/application-error` in the URL.

在上述代码中,如果一个错误冒泡到应用路由,那么应用将进入`catchall`路由,并在URL中显示`/application-error`
2 changes: 1 addition & 1 deletion source/bilingual_guides/routing/generated-objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Given you have the following route:

```javascript
App.Router.map(function() {
this.route('posts');
this.resource('posts');
});
```

Expand Down
78 changes: 78 additions & 0 deletions source/bilingual_guides/testing/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
Testing is a core part of the Ember framework and its development cycle.

测试是Ember框架及其开发周期中非常核心的部分。

Let's assume you are writing an Ember application which will serve as a blog.
This application would likely include models such as `user` and `post`. It would
also include interactions such as _login_ and _create post_. Let's finally
assume that you would like to have [automated tests] in place for your application.

假设需要编写一个提供博客服务的Ember应用。这个应用应该包括`user``post`模型,并包含_登录_和_创建博文_这样的交互。这里假定需要对应用进行[自动化测试]

There are two different classifications of tests that you will need:
**Integration** and **Unit**.

测试主要分为**集成测试****单元测试**两类:

### Integration Tests

### 集成测试

Integration tests are used to test user interaction and application flow. With
the example scenario above, some integration tests you might write are:

集成测试用于测试用户交互和应用流程。如上所述的博客应用,应该需要如下的集成测试:

* A user is able to log in via the login form.
* A user is able to create a blog post.
* A visitor does not have access to the admin panel.

* 用户应该可以通过一个登录窗口进行登录。
* 用户可以创建一篇博文。
* 访客没有访问管理面板的权限。

### Unit Tests

### 单元测试

Unit tests are used to test isolated chunks of functionality, or "units" without
worrying about their dependencies. Some examples of unit tests for the scenario
above might be:

单元测试用来测试独立的功能,或者说不需要关心其依赖部分的“单元”。对于博客应用可能的单元测试如下:

* A user has a role
* A user has a username
* A user has a fullname attribute which is the aggregate of its first and last
names with a space between
* A post has a title
* A post's title must be no longer than 50 characters

* 用户有角色划分
* 用户有用户名
* 用户有由用空格分隔的姓和名组成的全名
* 博文有标题
* 博文的标题不能超过50个字符

### Testing Frameworks

### 测试框架

[QUnit] is the default testing framework for this guide, but others are
supported through third-party adapters.

[QUnit]是本指南的缺省测试框架,不过其他的框架也可以通过第三方的适配器来支持。

### Contributing

### 贡献

The Ember testing guide provides best practices and examples on how to test your
Ember applications. If you find any errors or believe the documentation can be
improved, please feel free to [contribute].

Ember测试指南主要提供关于如何测试Ember应用的最佳实践和示例。如果发现任何错误或者文档可以得到更好的描述,请为此作出[贡献]

[自动化测试]: http://en.wikipedia.org/wiki/Test_automation
[QUnit]: http://qunitjs.com/
[贡献]: https://github.com/emberjs/website
Loading

0 comments on commit fea6d5c

Please sign in to comment.