Creating multiple records in a single model unit test


Hi there, I have some trouble on understanding the model testing setup. I want to write a test that ensures that I can handle multiple records of a model independently. Turns out: I can’t, but I’m sure you can. Can you help me to understand this issue?

app/model test.js

import DS from 'ember-data';

export default DS.Model.extend({
  name: DS.attr()

unit/models/test-test.js import { moduleForModel, test } from ‘ember-qunit’;

moduleForModel('test', 'Unit | Model | test', {
  // Specify the other units that are required for this test.
  needs: []

test('can handle multiple instances of test', function(assert) {
  const test = this.subject({name: "name1"});
  const test2 = this.subject({name: "name2"});

  assert.strictEqual(test.get("name"), "name1");
  assert.strictEqual(test2.get("name"), "name2"); //why is this name1?


Create more than one unit assertation, I guess that is a best pratice. I don’t know where two subject fit a unit case test.

  test(' name1 has name like name1', function(assert) { ... });
  test(' name2 has name like name2', function(assert) { ... });


First of all, tanks for your answer!

I maybe should give a little context of what I want to test. Consider a model called Band width a name attribute.

I want to make sure that I can have Metallica and Nirvana at the same time. And when Metallica change their name to Heavy Metallica, Nirvana suddenly seems to have this new name too.