Skip to content

Commit 149d975

Browse files
authored
Merge pull request #40 from ember-learn/add-acceptance-test
Add acceptance test
2 parents 66ae97e + 9e4c53a commit 149d975

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
/libpeerconnection.log
1616
npm-debug.log*
1717
testem.log
18+
package-lock.json

addon/components/docs-viewer/x-nav-item/component.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { inject as service } from '@ember/service';
22
import Component from '@ember/component';
33
import layout from './template';
4+
import { next } from '@ember/runloop';
45

56
export default Component.extend({
67
layout,
@@ -11,8 +12,14 @@ export default Component.extend({
1112

1213
didInsertElement() {
1314
this._super(...arguments);
14-
this.get('docsRoutes.items').addObject(this);
15-
},
15+
16+
next(() => {
17+
this.get('docsRoutes.items').addObject(this);
18+
});
19+
}
20+
1621
}).reopenClass({
22+
1723
positionalParams: ['label', 'route', 'model']
24+
1825
});

addon/services/docs-routes.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ export default Service.extend({
3535
});
3636
}),
3737

38-
currentRouteIndex: computed('router.router.currentURL', 'routeUrls.[]', function() {
38+
currentRouteIndex: computed('router.router.url', 'routeUrls.[]', function() {
3939
if (this.get('routeUrls.length')) {
4040
let router = this.get('router.router');
41-
let currentURL = router.get('rootURL') + router.get('currentURL');
41+
let currentURL = router.get('rootURL') + router.get('url');
4242
currentURL = currentURL
4343
.replace("//", "/") // dedup slashes
4444
.replace(/\/$/, ""); // remove trailing slash
4545
let index = this.get('routeUrls').indexOf(currentURL);
46-
assert(`DocsRoutes wasn't able to correctly detect the current route.`, index > -1);
46+
assert(`DocsRoutes wasn't able to correctly detect the current route. The current url is ${currentURL}`, index > -1);
4747
return index;
4848
}
4949
}),
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { test } from 'qunit';
2+
import moduleForAcceptance from '../../tests/helpers/module-for-acceptance';
3+
4+
moduleForAcceptance('Acceptance | Docs route test');
5+
6+
test('the docs route renders', function(assert) {
7+
visit('/docs');
8+
9+
andThen(function() {
10+
assert.equal(currentURL(), '/docs');
11+
});
12+
});

0 commit comments

Comments
 (0)