2

我的模型看起来像:

  App.MyUser = Ember.Object.extend();
  App.MyUser.reopenClass({
    attribute1: '',
    attribute2: '',
    getFunction: function() {
       ...
    },
    setFunction: function(foo) {
       ...
    }
  });

如何测试茉莉花中的功能?

   describe( "The user model", function () {  
               var user = null;
            App = Ember.Application.create();
            beforeEach(function(){
                user = App.MyUser.create();      
            });

            afterEach(function(){
                user = null;
            });

            it("should have an get function", function(){
                expect(user.getFunction).toBeDefined();
            });
        });

但我总是得到:

 Expected undefined to be defined.

如果我这样做我的模型:

 App.MyUser = Ember.Object.extend({......

没有reopenClass 它工作正常。但我需要使用reopenClass。那么它是怎样工作的?

4

0 回答 0