我正在构建一个相对直接的comment-list组件.我想传递可评论的模型(比如说a Post)并让组件负责创建,编辑和删除注释.现在我传递了各种各样的动作,而且非常脆弱.
如何在组件集成测试中创建Ember Data模型的真实实例?
我的直接想法是导入模型然后.create({})它,但错误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);
});
}
);
Run Code Online (Sandbox Code Playgroud)
有人有什么想法?