Rajat
Rajat

Reputation: 34148

Test non ember data models with ember qunit

I am using ember-qunit in an ember-cli application. My app is still not using ember-data for models.

The moduleForModel helper doesn't work at all. Is it required to have models extend from DS.Model to use ember-qunit?

Upvotes: 1

Views: 187

Answers (1)

Toran Billups
Toran Billups

Reputation: 27407

Honestly the best part about testing simple models (without ember-data in the mix) is that you can new them up like plain old javascript objects.

import { test, module } from 'qunit';
import Foo from 'myapp/models/foo';

module('my first unit test');

test('do something with a computed property', function(assert) {
    var foo = new Foo();
    foo.set('id', 1);
    foo.set('first', 'toran');
    foo.set('last', 'billups');
    //or this var foo = Foo.create({id: 1, first: 'toran', last: 'billups'});
    assert.equal(foo.get('full'), 'toran billups');
});

Upvotes: 1

Related Questions