Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember.js tests fail when using select

Tags:

ember.js

I am using Ember 1.8.1 and I updated my code from

{{view Ember.Select content=items}}

to

{{view "select" content=items}}

The problem now is that my tests fail and I get this error:

Error: Assertion Failed: select must be a subclass or an instance of Ember.View, not 
at new Error (native)
at Error.EmberError (http://0.0.0.0:4201/assets/vendor.js:27425:23)
at Object.Ember.assert (http://0.0.0.0:4201/assets/vendor.js:17039:15)
at handlebarsGetView (http://0.0.0.0:4201/assets/vendor.js:20093:13)
at EmberObject.create.helper (http://0.0.0.0:4201/assets/vendor.js:22801:19)
at viewHelper (http://0.0.0.0:4201/assets/vendor.js:23051:25)
at Object.anonymous (nea-client/templates/components/modal-workflow-create.js:18:54)
at http://0.0.0.0:4201/assets/vendor.js:10863:33
at CoreView.extend.render (http://0.0.0.0:4201/assets/vendor.js:55473:20)
at EmberRenderer_createElement [as createElement] (http://0.0.0.0:4201/assets/vendor.js:52700:16)

Any ideas how to fix this? If I revert the code to the old style the tests pass but I get a deprecation notice.

like image 847
Emad Avatar asked Dec 16 '14 10:12

Emad


1 Answers

In your test do this:

import Ember from 'ember';

moduleForComponent('my-foobar', 'MyFoobarComponent', {
  setup: function() {
    this.container.register('view:select', Ember.Select);
  }
}

Doing this type of thing moves us a bit closer to integration tests. There is talk about how to improve the current state of things here: https://github.com/rwjblue/ember-qunit/issues/74

like image 86
givanse Avatar answered Sep 30 '22 20:09

givanse