Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4838

Creating multiple records in a single model unit test

$
0
0

@stefan_kracht wrote:

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?
});

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4838

Trending Articles