-
Notifications
You must be signed in to change notification settings - Fork 409
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
Allow rename of lwc component inside of __tests__ directory #4225
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
b3d798a
fix: allow lwc component rename from inside __tests__ directory
de82062
fix: expand when clause, handle __test__ directory in path
51b544f
Merge branch 'develop' into dehru/fix-rename-component-test
dehru 6576044
Merge branch 'develop' into dehru/fix-rename-component-test
dehru 1226ba2
Merge branch 'develop' into dehru/fix-rename-component-test
dehru 8143f14
Merge branch 'develop' into dehru/fix-rename-component-test
dehru 8e10d5a
chore: update based on PR comments
07eb4f9
Merge branch 'dehru/fix-rename-component-test' of https://github.com/…
0c451c5
Merge branch 'develop' into dehru/fix-rename-component-test
gbockus-sf c574169
feat: refactor how we find the component directory
b25ab41
Merge branch 'dehru/fix-rename-component-test' of https://github.com/…
deb7dbc
Merge branch 'develop' into dehru/fix-rename-component-test
dehru bd7a94a
chore: renable tests
edd9d87
Merge branch 'develop' into dehru/fix-rename-component-test
dehru 7f1b926
chore: update message after input from doc
f000b36
Merge branch 'dehru/fix-rename-component-test' of https://github.com/…
5ac0d5a
Merge branch 'develop' into dehru/fix-rename-component-test
dehru 71e9e10
Merge branch 'develop' into dehru/fix-rename-component-test
dehru 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
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ import * as fs from 'fs'; | |
import * as path from 'path'; | ||
import * as sinon from 'sinon'; | ||
import * as vscode from 'vscode'; | ||
import {inputGuard, isNameMatch, RenameLwcComponentExecutor} from '../../../src/commands/forceRenameLightningComponent'; | ||
import {getLightningComponentDirectory, inputGuard, isNameMatch, RenameLwcComponentExecutor} from '../../../src/commands/forceRenameLightningComponent'; | ||
import { nls } from '../../../src/messages'; | ||
|
||
const RENAME_INPUT_DUP_ERROR = 'rename_component_input_dup_error'; | ||
|
@@ -399,5 +399,58 @@ describe('Force Rename Lightning Component', () => { | |
expect(exceptionThrownLwc).to.equal(true); | ||
expect(exceptionThrownAura).to.equal(true); | ||
}); | ||
|
||
}); | ||
|
||
describe('getLightningComponentDirectory function', () => { | ||
|
||
it('works with simple component folder', () => { | ||
const folders = ['src', 'main', 'default', 'lwc', 'cmp']; | ||
const folderPath = folders.join(path.sep); | ||
const parentDirectory = getLightningComponentDirectory(folderPath); | ||
expect(parentDirectory).to.equal(folderPath); | ||
}); | ||
|
||
it('works with __tests__ folder in the path', () => { | ||
const folders = ['src', 'main', 'default', 'lwc', 'cmp', '__tests__']; | ||
const folderPath = folders.join(path.sep); | ||
|
||
const parentFolder = folders.slice(0, -1); | ||
const parentFolderPath = parentFolder.join(path.sep); | ||
|
||
const parentDirectory = getLightningComponentDirectory(folderPath); | ||
expect(parentDirectory).to.equal(parentFolderPath); | ||
}); | ||
|
||
it('works with child folder of __tests__ folder', () => { | ||
const folders = ['lwc', 'cmp', '__tests__', 'data']; | ||
const folderPath = folders.join(path.sep); | ||
|
||
const parentFolder = folders.slice(0, -2); | ||
const parentFolderPath = parentFolder.join(path.sep); | ||
|
||
const parentDirectory = getLightningComponentDirectory(folderPath); | ||
expect(parentDirectory).to.equal(parentFolderPath); | ||
}); | ||
|
||
it('works with templates folder of component', () => { | ||
const folders = ['lwc', 'cmp', 'templates']; | ||
const folderPath = folders.join(path.sep); | ||
|
||
const parentFolder = folders.slice(0, -1); | ||
const parentFolderPath = parentFolder.join(path.sep); | ||
|
||
const parentDirectory = getLightningComponentDirectory(folderPath); | ||
expect(parentDirectory).to.equal(parentFolderPath); | ||
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. @jeffb-sfdc - I ended up with your first suggestion. I think this is a good balance. Thanks for the input. |
||
}); | ||
|
||
it('works with nested lwc folder of component', () => { | ||
const folders = ['src', 'main', 'default', 'lwc', 'other', 'lwc', 'cmp']; | ||
const folderPath = folders.join(path.sep); | ||
|
||
const parentDirectory = getLightningComponentDirectory(folderPath); | ||
expect(parentDirectory).to.equal(folderPath); | ||
}); | ||
|
||
}); | ||
}); |
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.
Basically, show the command to the user on anything inside the /lwc/ and /aura/ directories that have these file extensions. This includes the component subdirectory named
__tests__
and files inside there.If the user comes up with their own folder structure with a folder named
lwc
, this should still work to resolve the parent component directory.