-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from runspired/feat/sustain-hooks
Feat/sustain hooks
- Loading branch information
Showing
15 changed files
with
176 additions
and
15 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
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
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,39 @@ | ||
import { test } from 'qunit'; | ||
import Ember from 'ember'; | ||
import moduleForAcceptance from '../../tests/helpers/module-for-acceptance'; | ||
|
||
const { | ||
run | ||
} = Ember; | ||
|
||
moduleForAcceptance('Acceptance | sustain hooks'); | ||
|
||
test('Testing sustain-hooks', function(assert) { | ||
visit('/tests/sustain-hooks'); | ||
|
||
andThen(() => { | ||
assert.equal(currentURL(), '/tests/sustain-hooks'); | ||
|
||
let registry = this.application.__container__.lookup('-view-registry:main') || Ember.View.views; | ||
let component = registry['sustain-hooks-test']; | ||
|
||
assert.ok(component.get('didMoveTriggered'), 'didMove triggers on initial insert'); | ||
assert.ok(component.get('didMoveEvent'), 'didMove event triggers on initial insert'); | ||
|
||
assert.notOk(component.get('willMoveTriggered'), 'willMove does not trigger on initial insert'); | ||
assert.notOk(component.get('willMoveEvent'), 'willMove event does not trigger on initial insert'); | ||
|
||
assert.ok(component.get('insertTriggered'), 'didInsertElement properly triggers its super'); | ||
|
||
let controller = this.application.__container__.lookup('controller:tests/sustain-hooks'); | ||
|
||
run(() => { | ||
controller.set('showSustain', false); | ||
}); | ||
|
||
andThen(() => { | ||
assert.ok(component.get('willMoveTriggered'), 'willMove triggers when leaving a location'); | ||
assert.ok(component.get('willMoveEvent'), 'willMove event triggers when leaving a location'); | ||
}); | ||
}); | ||
}); |
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
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
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
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
{{sustain 'tests/sustain/components/test-title'}} | ||
{{sustain 'tests/sustain/components/test-title'}} | ||
{{sustain 'tests/sustain/components/tagless-title'}} |
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,5 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Controller.extend({ | ||
showSustain: true | ||
}); |
39 changes: 39 additions & 0 deletions
39
tests/dummy/app/routes/tests/sustain-hooks/has-hooks/component.js
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,39 @@ | ||
import Ember from 'ember'; | ||
|
||
const { | ||
Component, | ||
on | ||
} = Ember; | ||
|
||
export default Component.extend({ | ||
elementId: 'sustain-hooks-test', | ||
|
||
insertTriggered: false, | ||
willMoveTriggered: false, | ||
didMoveTriggered: false, | ||
|
||
willMoveEvent: false, | ||
didMoveEvent: false, | ||
|
||
didMove() { | ||
this.set('didMoveTriggered', true); | ||
}, | ||
|
||
willMove() { | ||
this.set('willMoveTriggered', true); | ||
}, | ||
|
||
_onDidMove: on('didMove', function() { | ||
this.set('didMoveEvent', true); | ||
}), | ||
|
||
_onWillMove: on('willMove', function() { | ||
this.set('willMoveEvent', true); | ||
}), | ||
|
||
willInsertElement() { | ||
this._super(); | ||
this.set('insertTriggered', true); | ||
} | ||
|
||
}); |
1 change: 1 addition & 0 deletions
1
tests/dummy/app/routes/tests/sustain-hooks/has-hooks/template.hbs
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 @@ | ||
<h1>Rendered!</h1> |
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,4 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Route.extend({ | ||
}); |
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,3 @@ | ||
{{#if showSustain}} | ||
{{sustain "tests/sustain-hooks/has-hooks"}} | ||
{{/if}} |
7 changes: 7 additions & 0 deletions
7
tests/dummy/app/routes/tests/sustain/components/tagless-title/component.js
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,7 @@ | ||
import Ember from 'ember'; | ||
import layout from './template'; | ||
|
||
export default Ember.Component.extend({ | ||
layout, | ||
tagName: '' | ||
}); |
7 changes: 7 additions & 0 deletions
7
tests/dummy/app/routes/tests/sustain/components/tagless-title/template.hbs
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,7 @@ | ||
{{#flexi-layout tagName="layout" class="sustain-test tagless-stuff flexi-layout"}} | ||
<h2 class="sustain-test">I ought to be sustained</h2> | ||
<p>If I was, the component above's ID will be identical.</p> | ||
{{/flexi-layout}} | ||
<div class="tagless-stuff"> | ||
<h3>More Tagless Stuff</h3> | ||
</div> |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
{{#link-to 'tests.sustain-b' id="next-sustain-test-page"}}Go to B{{/link-to}} | ||
{{sustain 'tests/sustain/components/test-title'}} | ||
{{sustain 'tests/sustain/components/test-title'}} | ||
{{sustain 'tests/sustain/components/tagless-title'}} |