-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose getRealPath and normalizeOptions (#194)
* Expose getRealPath * Expose normalizeOptions * Rename "Methods" to "Functions" for consistency * Document the exposed API * Rename getRealPath to resolvePath and hide normalizeOptions * Improve wording * Remove the context from the resolvePath call * Use reselect to memoize normalizeOptions
- Loading branch information
Showing
9 changed files
with
171 additions
and
77 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
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
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,36 @@ | ||
import normalizeOptions from '../src/normalizeOptions'; | ||
|
||
|
||
describe('normalizeOptions', () => { | ||
beforeEach(() => { | ||
normalizeOptions.resetRecomputations(); | ||
}); | ||
|
||
it('should return the memoized options when the dirnames are the same', () => { | ||
const options = {}; | ||
const result = normalizeOptions('path/a.js', options); | ||
const result2 = normalizeOptions('path/b.js', options); | ||
|
||
expect(result).toBe(result2); | ||
expect(normalizeOptions.recomputations()).toEqual(1); | ||
}); | ||
|
||
it('should return the memoized options when the special paths are the same', () => { | ||
const options = {}; | ||
const result = normalizeOptions('unknown', options); | ||
const result2 = normalizeOptions('unknown', options); | ||
|
||
expect(result).toBe(result2); | ||
expect(normalizeOptions.recomputations()).toEqual(1); | ||
}); | ||
|
||
it('should recompute when the options object is not the same', () => { | ||
const options = {}; | ||
const options2 = {}; | ||
const result = normalizeOptions('path/to/file.js', options); | ||
const result2 = normalizeOptions('path/to/file.js', options2); | ||
|
||
expect(result).not.toBe(result2); | ||
expect(normalizeOptions.recomputations()).toEqual(2); | ||
}); | ||
}); |