I’ve created a small mixin that helps a component to be hidden when the user clicks outside of the component. I’d now like to add a test for it, where I trigger a click event outside a component that extends the mixin.
All I want to test is that a method called onOutsideClick
is called. For this, I’m trying to draw inspiration from: https://github.com/nucleartide/ember-outside-click
But when I do this:
const HideOnOutsideClickObject = Ember.Component.extend(HideOnOutsideClick, {
})
test('click outside', function(assert) {
const element = this.$()[0]
const event = document.createEvent('MoseEvents')
event.initEvent(event, true, true)
element.dispatchEvent(event)
assert.ok(HideOnOutsideClickObject.onOutsideClick)
})
I get an error saying that this.$() is not a function
. What am I missing?
I’ve of course imported the mixin as I should.
Aucun commentaire:
Enregistrer un commentaire