This repository has been archived by the owner on Dec 8, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 21
Allowing you to test templates from MU co-located tests #33
Closed
mansona
wants to merge
6
commits into
ember-cli:master
from
stonecircle:feature/test-private-components
Closed
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2f57fd0
make it work for components inside `-components` folders
mansona ad4229d
implementing the nested components version
mansona 7fcb9ce
simplifying the implementation
mansona c8aa333
Add tests for several complex module name cases
mixonic 4d24a0d
Merge pull request #1 from mixonic/feature/test-private-components
mansona ebbeed4
allowing this to work with windows
mansona File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,20 @@ | ||
'use strict'; | ||
|
||
module.exports = function (filename) { | ||
const parts = filename.split('/'); | ||
|
||
// remove application name | ||
parts.splice(0, 1); | ||
|
||
const componentsIndex = parts.indexOf('-components'); | ||
|
||
if (componentsIndex > 0) { | ||
parts.splice(componentsIndex); | ||
} else { | ||
parts.splice(parts.length - 2); | ||
} | ||
|
||
parts.push('template'); | ||
|
||
return parts.join('/') + '.hbs'; | ||
} |
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,13 @@ | ||
'use strict'; | ||
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. typo here, should read 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);
} |
||
expect(parseModuleName('emberconf/src/ui/routes/application/-components/footer-prompt/component-test.js')).toEqual('src/ui/routes/application.hbs'); | ||
}) | ||
|
||
it('should return the parent component when using a component local component', function() { | ||
expect(parseModuleName('emberconf/src/ui/components/icon-emberconf/facey-face/component-test.js')).toEqual('src/ui/components/icon-emberconf/template.hbs'); | ||
}) | ||
}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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