-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: dynamic segments are not parsed on model-less resources (#510)
* fix: dynamic segments are not parsed on model-less resources * style: remove unecessary interpolation
- Loading branch information
1 parent
56321bb
commit 53378f6
Showing
3 changed files
with
66 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// @flow | ||
import { expect } from 'chai'; | ||
import { it, describe, before } from 'mocha'; | ||
|
||
import { getTestApp } from '../../../../test/utils/get-test-app'; | ||
import createReplacer from '../utils/create-replacer'; | ||
|
||
describe('module "router"', () => { | ||
describe('util createReplacer()', () => { | ||
let subject; | ||
|
||
before(async () => { | ||
const app = await getTestApp(); | ||
// $FlowIgnore | ||
const healthController = app.controllers.get('health'); | ||
const { constructor: HealthController } = healthController; | ||
|
||
class AdminHealthController extends HealthController {} | ||
|
||
subject = createReplacer(new Map([ | ||
// $FlowIgnore | ||
['posts', app.controllers.get('posts')], | ||
['health', healthController], | ||
// $FlowIgnore | ||
['admin/posts', app.controllers.get('admin/posts')], | ||
['admin/health', new AdminHealthController({ | ||
namespace: 'admin' | ||
})] | ||
])); | ||
}); | ||
|
||
it('returns an instance of RegExp', () => { | ||
expect(subject).to.be.an.instanceOf(RegExp); | ||
}); | ||
|
||
it('correctly replaces dynamic parts', () => { | ||
expect( | ||
'posts/1'.replace(subject, '$1/:dynamic') | ||
).to.equal('posts/:dynamic'); | ||
|
||
expect( | ||
'health/1'.replace(subject, '$1/:dynamic') | ||
).to.equal('health/:dynamic'); | ||
}); | ||
}); | ||
}); |
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