-
-
Notifications
You must be signed in to change notification settings - Fork 21
Allowing you to test templates from MU co-located tests #33
Allowing you to test templates from MU co-located tests #33
Conversation
@mansona I don't see a description anywhere of what exactly this is fixing 🤔 |
index.js
Outdated
if (filename.includes('-components')) { | ||
options.meta.moduleName = parseModuleName(filename); | ||
} else if (filenameParts[2] === 'components' && filenameParts.length > 5) { | ||
options.meta.moduleName = parseModuleName(filename); |
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.
I wonder if it would be better if parseModuleName does the filename checking and returns null
if the filename is irrelevant. So this could be
let filename = state.file.opts.filename;
let moduleName = parseModuleName(filename);
if (moduleName) {
options.meta.moduleName = moduleName;
}
@Turbo87 I think this is trying to fix the |
@Turbo87 in module unification, you may want to have an integration test for a private component, for example: |
@iezer I have taken your advice, much nicer looking 🎉 I'm still not 100% happy with the style of the |
tests/parse-module-name.js
Outdated
const parseModuleName = require('../lib/parse-module-name'); | ||
|
||
describe('parse-module-name helper', function() { | ||
it('should return applicaiton template when using a route local -component', function() { |
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 here, should read application
Also can you add a few more test for the null case?
it('should return null for public components', function() {
expect(parseModuleName('emberconf/src/ui/components/foo-bar/component-test.js').toEqual(null);
}
it('should return null for public components in test folder', function() {
expect(parseModuleName('emberconf/tests/integration/components/foo-bar/component-test.js').toEqual(null);
}
This repo has another PR #11 to support passing an options hash to the precompiler. It's 2 years old but I think we may want to merge that PR as well as this one. There may be other use cases where we want to pass in the options hash. The two PRs can work together. If there is no |
Add tests for several complex module name cases
lib/parse-module-name.js
Outdated
'use strict'; | ||
|
||
module.exports = function (filename) { | ||
let parts = filename.split('/'); |
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.
what about windows?
|
||
if (lastPrivateCollectionIndex !== -1) { | ||
// TODO: We likely do not need new array allocations for the prefix and | ||
// collection parts |
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.
is this still WIP? otherwise this comment should be removed
return `${prefixString}/${collectionParts.join('/')}/template.hbs`; | ||
} | ||
return `${prefixString}/template.hbs`; | ||
} |
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.
if (collectionParts.length > 3) {
collectionParts.splice(-2);
return `${prefixString}/${collectionParts.join('/')}/template.hbs`;
} else if (collectionParts.length === 3) {
return `${prefixString}/template.hbs`;
}
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.
also it seems that the route with collectionParts.length < 3
is not currently tested
FYI - #37 will introduce a conflict here, but hopefully it isn't too bad. Also, I made sure to avoid setting |
how complicated is that? :) |
Unfortunately, I don't know, I haven't had a chance to look at this recently and I don't know if I'll get a chance this week 😖 |
anyway I can give a look? |
Closing this in favor of #42 |
This is a result of a pairing session with @iezer trying to get the integration tests on the emberconf2018 MU app to work: https://github.com/201-created/emberconf-schedule-2018/blob/integration-tests/src/ui/routes/application/-components/footer-prompt/component-test.js#L13
We have come up with 2 scenarios that it needs to work with:
-components
folders in routesThis PR is reasonably hacky 😂 it's very much supposed to be a "here this works, how should we make it play nice" kind of implementation.