-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Target Element for scroll top (#132)
* Add support for targetElement config * defaults * set default to target element for scrollTop * add basic acceptance test WIP * modify config in dummy route * link to images correctly * rework index * update env * comment out targetElement for tests * update app-scheduler to 0.2.2 * add some comments * take name out of test * update readme * update name in test * add scrollY assertion to first test * use nested route...oops revert * update readme * update imports in readme * basic assertion * restart build * restart again * add a few more tests * update based on comments * add version 0.7.0 to pkg.json
- Loading branch information
1 parent
1efa8ee
commit 948f25d
Showing
18 changed files
with
308 additions
and
65 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
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,15 +1,55 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupApplicationTest } from 'ember-qunit'; | ||
import { visit, click, currentURL } from '@ember/test-helpers'; | ||
import { visit, click, currentURL, triggerEvent } from '@ember/test-helpers'; | ||
import config from 'dummy/config/environment'; | ||
|
||
module('Acceptance | basic functionality', function(hooks) { | ||
setupApplicationTest(hooks); | ||
|
||
hooks.beforeEach(function() { | ||
document.getElementById('ember-testing-container').scrollTop = 0; | ||
}); | ||
hooks.afterEach(function() { | ||
config['routerScroll'] = {}; | ||
}); | ||
|
||
test('The application should work when loading a page and clicking a link', async function(assert) { | ||
config['routerScroll'] = { | ||
scrollElement: '#ember-testing-container' | ||
} | ||
|
||
await visit('/'); | ||
|
||
// testing specific | ||
let container = document.getElementById('ember-testing-container'); | ||
assert.equal(container.scrollTop, 0); | ||
|
||
await document.getElementById('monster').scrollIntoView(false); | ||
await triggerEvent(window, 'scroll'); | ||
|
||
assert.ok(container.scrollTop > 0); | ||
|
||
await click('a[href="/next-page"]'); | ||
|
||
assert.equal(currentURL(), '/next-page'); | ||
}); | ||
|
||
test('The application should work when loading a page and clicking a link to target an element to scroll to', async function(assert) { | ||
config['routerScroll'] = { | ||
scrollElement: '#target-main' | ||
} | ||
|
||
await visit('/target'); | ||
|
||
// testing specific | ||
let container = document.getElementById('ember-testing-container'); | ||
assert.equal(container.scrollTop, 0); | ||
|
||
await document.getElementById('monster').scrollIntoView(false); | ||
assert.ok(container.scrollTop > 0); | ||
|
||
await click('a[href="/target-next-page"]'); | ||
|
||
assert.equal(currentURL(), '/target-next-page'); | ||
}); | ||
}); |
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,4 @@ | ||
import Route from '@ember/routing/route'; | ||
|
||
export default 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,4 @@ | ||
import Route from '@ember/routing/route'; | ||
|
||
export default 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,4 @@ | ||
import Route from '@ember/routing/route'; | ||
|
||
export default 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
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
Oops, something went wrong.