Tôi đang xây dựng một thành phần tương đối thẳng comment-list
. Tôi muốn chuyển sang mô hình có thể nhận xét (giả sử là Post
) và yêu cầu tạo thành phần, chỉnh sửa, xóa nhận xét. Ngay bây giờ tôi đã vượt qua tất cả các hành động khác nhau và nó cực kỳ giòn.Ember.js: Cách tích hợp các thành phần thử nghiệm tương tác với các mô hình dữ liệu ember
Làm cách nào để tạo một trường hợp thực sự của mô hình Dữ liệu Ember trong thử nghiệm tích hợp thành phần?
suy nghĩ trước mắt của tôi là nhập khẩu các mô hình sau đó .create({})
nó nhưng mà lỗi với use this.store.createRecord() instead
/* jshint expr:true */
import { assert } from 'chai';
import { describeComponent, it } from 'ember-mocha';
import hbs from 'htmlbars-inline-precompile';
import Post from 'ownersup-client/post/model';
describeComponent('comment-list', 'Integration: CommentListComponent', {
integration: true
},
function() {
it('renders all of the comments', function() {
const model = Post.create({ title: 'title' });
model.get('comments').createRecord({ body: 'One Comment' })
this.render(hbs`{{comment-list model=model}}`);
assert.lengthOf(this.$('.comment-list-item'), 1);
});
}
);
Bất cứ ai có bất kỳ suy nghĩ?
** this.inject.service ('store'); cho phép model = this.get ('store'). CreateRecord ('fo'); ** chỉ ném một lỗi cho tôi – SuperUberDuper