This repository has been archived by the owner on Oct 10, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Allow regex groups *after* keyword groups (#335)
- Loading branch information
Showing
5 changed files
with
93 additions
and
8 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
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
25 changes: 25 additions & 0 deletions
25
test/single-workspace-tests/extension/utilities/utilityFunctions.test.ts
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,25 @@ | ||
import * as chai from 'chai'; | ||
chai.should(); | ||
|
||
import { KeywordImportGroup, ImportGroupKeyword, RegexImportGroup } from '../../../../src/extension/import-grouping'; | ||
import { importGroupSortForPrecedence } from '../../../../src/extension/utilities/utilityFunctions'; | ||
|
||
describe('utilityFunctions', () => { | ||
describe('importGroupSortForPrecedence', () => { | ||
it('should prioritize regexes, leaving original order untouched besides that', () => { | ||
const initialList = [ | ||
new KeywordImportGroup(ImportGroupKeyword.Modules), | ||
new KeywordImportGroup(ImportGroupKeyword.Plains), | ||
new RegexImportGroup("/cool-library/"), | ||
new RegexImportGroup("/cooler-library/"), | ||
new KeywordImportGroup(ImportGroupKeyword.Workspace), | ||
] | ||
const expectedList = initialList.slice(2, 4) | ||
.concat(initialList.slice(0, 2)) | ||
.concat(initialList.slice(4)) | ||
|
||
importGroupSortForPrecedence(initialList).should.deep.equal(expectedList, | ||
'Regex Import Groups should appear first (and that should be the only change)') | ||
}); | ||
}); | ||
}); |