-
-
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.
- Loading branch information
Showing
6 changed files
with
140 additions
and
7 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
67 changes: 67 additions & 0 deletions
67
packages/ember/tests/routing/router_service_test/urlFor_test.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,67 @@ | ||
import { inject } from 'ember-runtime'; | ||
import { Component } from 'ember-glimmer'; | ||
import { Route, NoneLocation } from 'ember-routing'; | ||
import { | ||
get, | ||
set | ||
} from 'ember-metal'; | ||
import { | ||
RouterTestCase, | ||
moduleFor | ||
} from 'internal-test-helpers'; | ||
|
||
import { isFeatureEnabled } from 'ember-metal'; | ||
|
||
if (isFeatureEnabled('ember-routing-router-service')) { | ||
moduleFor('Router Service - urlFor', class extends RouterTestCase { | ||
constructor() { | ||
super(); | ||
} | ||
|
||
['@test RouterService#urlFor returns URL for simple route'](assert) { | ||
assert.expect(1); | ||
|
||
return this.visit('/').then(() => { | ||
let expectedURL = this.routerService.urlFor('parent.child'); | ||
|
||
assert.equal('/child', expectedURL); | ||
}); | ||
} | ||
|
||
['@test RouterService#urlFor returns URL for simple route with dynamic segments'](assert) { | ||
assert.expect(1); | ||
|
||
let dynamicModel = { id: 1, contents: 'much dynamicism' }; | ||
|
||
return this.visit('/').then(() => { | ||
let expectedURL = this.routerService.urlFor('dynamic', dynamicModel); | ||
|
||
assert.equal('/dynamic/1', expectedURL); | ||
}); | ||
} | ||
|
||
['@test RouterService#urlFor returns URL for simple route with query params'](assert) { | ||
assert.expect(1); | ||
|
||
let queryParams = { queryParams: { foo: 'bar' } }; | ||
|
||
return this.visit('/').then(() => { | ||
let expectedURL = this.routerService.urlFor('parent.child', queryParams); | ||
|
||
assert.equal('/child?foo=bar', expectedURL); | ||
}); | ||
} | ||
|
||
['@test RouterService#urlFor returns URL for simple route with dynamic segments and query params'](assert) { | ||
assert.expect(1); | ||
|
||
let queryParams = { queryParams: { foo: 'bar' } }; | ||
|
||
return this.visit('/').then(() => { | ||
let expectedURL = this.routerService.urlFor('dynamic', { id: 1 }, queryParams); | ||
|
||
assert.equal('/dynamic/1?foo=bar', expectedURL); | ||
}); | ||
} | ||
}); | ||
} |
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