Ember.js EmberJS:使用ember mocha,如何使用商店测试序列化程序/控制器

Ember.js EmberJS:使用ember mocha,如何使用商店测试序列化程序/控制器,ember.js,mocha.js,ember-cli,ecmascript-6,chai,Ember.js,Mocha.js,Ember Cli,Ecmascript 6,Chai,我正在重写一个ember项目以使用ember cli。由于Mocha的describeModel函数引入了一个存储,但describeModule没有,所以我一直在重写序列化程序测试 import { expect, assert } from 'chai'; import { describeModel,it } from 'ember-mocha'; describeModel('connection','Connection Desc', { needs: ['model:result'

我正在重写一个ember项目以使用ember cli。由于Mocha的
describeModel
函数引入了一个存储,但
describeModule
没有,所以我一直在重写序列化程序测试

import { expect, assert } from 'chai';
import { describeModel,it } from 'ember-mocha';

describeModel('connection','Connection Desc', { needs: ['model:result'] },
  function() {
    it('exists', function() {
      var model = this.subject();
      var store = this.store();
      expect(model).to.be.ok;
    });
});
作为一种解决方法,我正在手动创建一个商店,但我想这不是很方便,而且我确信有一种更可读的方法来实现这一点:

import App from '../../../app';
import { expect, assert } from 'chai';
import { describeModule, it } from 'ember-mocha';

describeModule( 'serializer:result', 'Result Serializer', { needs: ['model:result'] },

function() {

  it('converts a single item on a result to a one element array', function(){
    var serializer = this.subject();

    App.ApplicationStore = DS.Store.extend({
      adapter: DS.MochaAdapter
    });
    var store = App.ApplicationStore.create({
      container: this.container
    });

    expect(
      serializer.extractArray( store, store.modelFor('result'), {"results":[]})
    ).to.be.an.instanceOf(Array).and.have.lengthOf(0);
  });

  it("changes the recycle mode properly.", function () {

      Mediator.ApplicationStore = DS.Store.extend({
        adapter: DS.MochaAdapter
      });
      var store = Mediator.ApplicationStore.create({
        container: this.container
      });

      var model = store.createRecord('result', {});
      // ...          
    });
});
这是存在的,但嘲笑商店的每一种可能的方法听起来并不诱人

对于上面的示例,是否有一种较短的方法来获取
DS.Store
实例(类似于
主题