相关疑难解决方法(0)

Ember.js:如何集成测试与ember-data模型交互的组件

我正在构建一个相对直接的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)

有人有什么想法?

ember.js ember-data ember-cli

7
推荐指数
3
解决办法
1906
查看次数

标签 统计

ember-cli ×1

ember-data ×1

ember.js ×1