-
-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
defaultType support, mv partials code to resolver #192
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,11 +32,13 @@ export let config = { | |
types: [ 'template' ] | ||
}, | ||
routes: { | ||
defaultType: 'route', | ||
group: 'ui', | ||
privateCollections: ['components'], | ||
types: ['route', 'controller', 'template'] | ||
}, | ||
services: { | ||
defaultType: 'service', | ||
types: ['service'] | ||
} | ||
} | ||
|
@@ -51,32 +53,73 @@ function buildMockRequire() { | |
module('RequireJS Registry', { | ||
beforeEach() { | ||
this.mockRequire = buildMockRequire(); | ||
this.mockRequire.entries = {}; | ||
this.config = config; | ||
this.registry = new RequireJSRegistry(this.config, 'src', this.mockRequire); | ||
}, | ||
|
||
addModule(name, module) { | ||
this.mockRequire.entries[name] = module; | ||
} | ||
|
||
}); | ||
|
||
test('Normalize', function(assert) { | ||
assert.expect(10); | ||
test('basic get', function(assert) { | ||
assert.expect(8); | ||
|
||
[ | ||
/* | ||
* Over time lets move these general cases into specific tests that | ||
* describe their aim. | ||
*/ | ||
[ 'router:/my-app/main/main', 'my-app/src/router' ], | ||
[ 'route:/my-app/routes/application', 'my-app/src/ui/routes/application/route' ], | ||
[ 'template:/my-app/routes/application', 'my-app/src/ui/routes/application/template' ], | ||
[ 'component:/my-app/components/my-input', 'my-app/src/ui/components/my-input/component' ], | ||
[ 'template:/my-app/routes/components/my-input', 'my-app/src/ui/components/my-input/template' ], | ||
[ 'template:/my-app/components/my-input', 'my-app/src/ui/components/my-input/template' ], | ||
[ 'component:/my-app/components/my-input/my-button', 'my-app/src/ui/components/my-input/my-button/component' ], | ||
[ 'template:/my-app/components/my-input/my-button', 'my-app/src/ui/components/my-input/my-button/template' ], | ||
[ 'template:/my-app/routes/-author', 'my-app/src/ui/partials/author' ], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like the other changes in this PR make partials still work, why remove the test? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added a comment about this in the source- I'd like to see this bulk test be simmered down into smaller focused tests with better descriptions of the intent. @iezer and I took the first steps toward some utilities to help keep those test terse. |
||
[ 'service:/my-app/services/auth', 'my-app/src/services/auth/service' ] | ||
[ 'template:/my-app/components/my-input/my-button', 'my-app/src/ui/components/my-input/my-button/template' ] | ||
] | ||
.forEach(([ lookupString, expected ]) => { | ||
let expectedModule = {}; | ||
this.mockRequire.entries = { | ||
[expected]: {default: expectedModule} | ||
}; | ||
let actualModule = this.registry.get(lookupString); | ||
assert.equal(actualModule, expectedModule, `normalize ${lookupString} -> ${expected}`); | ||
assert.equal(actualModule, expectedModule, `get ${lookupString} -> ${expected}`); | ||
}); | ||
}); | ||
|
||
test('typed module name with default export', function(assert) { | ||
let expectedModule = {}; | ||
this.addModule(`my-app/src/ui/routes/index/route`, {default: expectedModule}); | ||
|
||
let actualModule = this.registry.get(`route:/my-app/routes/index`); | ||
assert.equal( | ||
actualModule, expectedModule, | ||
`resolved the module` | ||
); | ||
}); | ||
|
||
test('un-typed module name with default export when resolved type is the defaultType', function(assert) { | ||
let expectedModule = {}; | ||
this.addModule(`my-app/src/ui/routes/index`, {default: expectedModule}); | ||
|
||
let actualModule = this.registry.get(`route:/my-app/routes/index`); | ||
assert.equal( | ||
actualModule, expectedModule, | ||
`resolved the module` | ||
); | ||
}); | ||
|
||
test('un-typed module name with default export when resolved type is not the defaultType', function(assert) { | ||
let expectedModule = {}; | ||
this.addModule(`my-app/src/ui/routes/index`, {default: expectedModule}); | ||
|
||
let actualModule = this.registry.get(`template:/my-app/routes/index`); | ||
assert.notOk( | ||
actualModule, | ||
`did not resolve the module` | ||
); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo