How to call Object.set in a simple test?


#1

I am unable to call the “set” function from a test. Test is really simple. What am I doing wrong.

import Ember from 'ember';
module('Unit');


test('Set', function () {
  var a = Ember.Object.extend({a: null});
  a.set('a', 'a');
});

The a.set call fails with:

Source: TypeError: undefined is not a function at Object. (http://localhost:7357/assets/a.js:4712:7) at Object.Test.run (http://localhost:7357/assets/test-support.js:1179:28) at http://localhost:7357/assets/test-support.js:1308:11 at process (http://localhost:7357/assets/test-support.js:867:24) at begin (http://localhost:7357/assets/test-support.js:912:2) at http://localhost:7357/assets/test-support.js:928:4


#2

var a = Ember.Object.extend({a: null});

Ember.Object.extend is how you define a class.

To create an instance which has .set method, you have to use Ember.Object.create({a: null})