In Ember js, how to create or mock hasMany relationship in unit test
<p>I'm unit-testing a model which has properties with <code>DS.hasMany()</code> relationships. Whenever I do the following unit-test, I keep getting this error in my test-runner:
<code>Error: Assertion Failed: All elements of a hasMany relationship must be instances of DS.Model, you passed [&lt;Ember.Object:ember367&gt;,&lt;Ember.Object:ember368&gt;]</code></p>

<p>Can someone shed some light into this, please?</p>

<h3>Model:</h3>

<pre><code>export default DS.Model.extend({
  accounts: DS.hasMany('account'),
  servicesAccounts: DS.hasMany('services-account'),
  address: MF.fragment('address'),
  appEligibilities: MF.fragmentArray('app-eligibility'),

  appsForPremise: Ember.computed('accounts', function () {
    return DS.PromiseArray.create({
      promise: this.get('store').find('app', {
        account: this.get('accounts').mapBy('id')
      })
    });
  })
});
</code></pre>

<h3>Model uni-test:</h3>

<pre><code>import { moduleForModel, test } from 'ember-qunit';
import Ember from 'ember';

moduleForModel('premise', 'Unit | Model | premise', {
  needs: [
    'model:account',
    'model:services-account',
    'model:address',
    'model:app-eligibility'
  ]
});

test('Apps for premise', function (assert) {
  let model = this.subject({
      accounts: [Ember.Object.create({
        id: 'account-1'
      }),
      Ember.Object.create({
        id: 'account-2'
      })],
      appsForPremise: sinon.spy()
    });

  Ember.run(() =&gt; {
  });

  assert.equal(model.get('appsForPremise'), '[{id: account-1}, {id: account-2}]');

});
</code></pre>