-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Duncan Graham Walker
committed
May 21, 2016
1 parent
4c4a64f
commit 4a77c19
Showing
1 changed file
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import Ember from 'ember'; | ||
import { moduleForComponent, test } from 'ember-qunit'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
|
||
const { run } = Ember; | ||
|
||
moduleForComponent('tooltip-on-component', 'Integration | Option | actions', { | ||
integration: true | ||
}); | ||
|
||
test('It animates with delay passed as a number', function(assert) { | ||
const actionsCalledHash = { | ||
'onTooltipDestroy': 0, | ||
'onTooltipHide': 0, | ||
'onTooltipRender': 0, | ||
'onTooltipShow': 0, | ||
}; | ||
|
||
assert.expect(10); | ||
|
||
/* Setup the actions and handlers... */ | ||
|
||
Object.keys(actionsCalledHash).forEach((action) => { | ||
this.on(action, () => { | ||
assert.ok(true, `Should call ${action}`); | ||
|
||
/* Count the calls... */ | ||
|
||
actionsCalledHash[action]++; | ||
}); | ||
}); | ||
|
||
/* Now, let's go through the component lifecycle */ | ||
|
||
this.render(hbs` | ||
{{#unless destroyTooltip}} | ||
{{tooltip-on-component | ||
onTooltipDestroy='onTooltipDestroy' | ||
onTooltipHide='onTooltipHide' | ||
onTooltipRender='onTooltipRender' | ||
onTooltipShow='onTooltipShow' | ||
}} | ||
{{/unless}} | ||
`); | ||
|
||
/* Check render */ | ||
|
||
assert.equal(actionsCalledHash.onTooltipRender, 1, | ||
'Should have called render'); | ||
|
||
assert.equal(actionsCalledHash.onTooltipShow, 0, | ||
'Should not have called show'); | ||
|
||
/* Check show */ | ||
|
||
run(() => { | ||
this.$().trigger('mouseover'); | ||
}); | ||
|
||
assert.equal(actionsCalledHash.onTooltipShow, 1, | ||
'Should have called show'); | ||
|
||
assert.equal(actionsCalledHash.onTooltipHide, 0, | ||
'Should not have called hide'); | ||
|
||
run(() => { | ||
this.$().trigger('mouseleave'); | ||
}); | ||
|
||
assert.equal(actionsCalledHash.onTooltipHide, 1, | ||
'Should have called hide'); | ||
|
||
/* Check destroy */ | ||
|
||
this.set('destroyTooltip', true); | ||
|
||
assert.equal(actionsCalledHash.onTooltipDestroy, 1, | ||
'Should have called destroy'); | ||
|
||
}); |