-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Temporarily commenting out deprecation warning until fixed. Adding te…
…sts for `currentRouteName`. Removing `urlFor` until query params perf can be determined
- Loading branch information
Showing
3 changed files
with
125 additions
and
25 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,120 @@ | ||
import Logger from 'ember-console'; | ||
import { Controller } from 'ember-runtime'; | ||
import { Route } from 'ember-routing'; | ||
import { | ||
run, | ||
get | ||
} from 'ember-metal'; | ||
import { jQuery } from 'ember-views'; | ||
import inject from 'ember-runtime/inject'; | ||
import { ApplicationTestCase, moduleFor } from 'internal-test-helpers'; | ||
|
||
|
||
var Router, App, router, registry, container, originalLoggerError; | ||
|
||
moduleFor('Router Serivce - main', class extends ApplicationTestCase { | ||
['@test currentRouteName is correctly set for top level route'](assert) { | ||
assert.expect(1); | ||
|
||
let routerService; | ||
|
||
this.router.map(function() { | ||
this.route('parent', { path: '/' }); | ||
}); | ||
|
||
this.registerRoute('parent', Route.extend({ | ||
router: inject.service(), | ||
init() { | ||
routerService = get(this, 'router'); | ||
} | ||
})); | ||
|
||
return this.visit('/').then(() => { | ||
assert.equal(routerService.get('currentRouteName'), 'parent'); | ||
}); | ||
} | ||
|
||
['@test currentRouteName is correctly set for child route'](assert) { | ||
assert.expect(1); | ||
|
||
let routerService; | ||
|
||
this.router.map(function() { | ||
this.route('parent', { path: '/' }, function() { | ||
this.route('child'); | ||
}); | ||
}); | ||
|
||
this.registerRoute('parent.child', Route.extend({ | ||
router: inject.service(), | ||
init() { | ||
routerService = get(this, 'router'); | ||
} | ||
})); | ||
|
||
return this.visit('/child').then(() => { | ||
assert.equal(routerService.get('currentRouteName'), 'parent.child'); | ||
}); | ||
} | ||
|
||
['@test currentRouteName is correctly set after transition'](assert) { | ||
assert.expect(1); | ||
|
||
let routerService; | ||
|
||
this.router.map(function() { | ||
this.route('parent', { path: '/' }, function() { | ||
this.route('child'); | ||
this.route('sibling'); | ||
}); | ||
}); | ||
|
||
this.registerRoute('parent.child', Route.extend({ | ||
router: inject.service(), | ||
init() { | ||
routerService = get(this, 'router'); | ||
}, | ||
|
||
afterModel() { | ||
this.transitionTo('parent.sibling'); | ||
} | ||
})); | ||
|
||
return this.visit('/child').then(() => { | ||
assert.equal(routerService.get('currentRouteName'), 'parent.sibling'); | ||
}); | ||
} | ||
|
||
['@test currentRouteName is correctly set on each transition'](assert) { | ||
assert.expect(3); | ||
|
||
let routerService; | ||
|
||
this.router.map(function() { | ||
this.route('parent', { path: '/' }, function() { | ||
this.route('child'); | ||
this.route('sister'); | ||
this.route('brother') | ||
}); | ||
}); | ||
|
||
this.registerRoute('parent.child', Route.extend({ | ||
router: inject.service(), | ||
init() { | ||
routerService = get(this, 'router'); | ||
} | ||
})); | ||
|
||
return this.visit('/child').then(() => { | ||
assert.equal(routerService.get('currentRouteName'), 'parent.child'); | ||
|
||
return this.visit('/sister').then(() => { | ||
assert.equal(routerService.get('currentRouteName'), 'parent.sister'); | ||
|
||
return this.visit('/brother').then(() => { | ||
assert.equal(routerService.get('currentRouteName'), 'parent.brother'); | ||
}); | ||
}); | ||
}); | ||
} | ||
}); |