Skip to content

Instantly share code, notes, and snippets.

@zzarcon
Created October 20, 2014 10:08
Show Gist options
  • Save zzarcon/d349e0f21f7e7c81813b to your computer and use it in GitHub Desktop.
Save zzarcon/d349e0f21f7e7c81813b to your computer and use it in GitHub Desktop.
Components tests
var view;
module('Computed properties', {
setup: function() {
view = Ember.View.create({
template: Ember.Handlebars.compile(
'{{my-component name="hector"}}'
)
});
},
teardown: function() {
App.reset();
}
});
test('', function(assert) {
assert.equal(view.$().contains('Hector'), true);
});
@fernandodrumond
Copy link

You need to add the view to the DOM in order to evaluate view.$() and $().contains doesn't exist:

var view;
module('Computed properties', {
  setup: function() {
    view = Ember.View.create({
      template: Ember.Handlebars.compile(
        '{{my-component name="hector"}}'
      )
    });

    Em.run(function() {
      view.appendTo('body');
    });
  },

  teardown: function() {
    App.reset();
  }
});

test('', function(assert) {
  assert.equal(!!view.$(':contains(Hector)').length, true);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment