This repository has been archived by the owner on Jan 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable stripProjectRoot by default (& tests)
- Added Windows path support on macOS/Linux - Wrote some tests for stripping the project root
- Loading branch information
Showing
2 changed files
with
87 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,59 @@ | ||
const { | ||
stripProjectRoot, | ||
upload, | ||
} = require('./index'); | ||
|
||
test('upload function exists', () => { | ||
expect(typeof upload).toBe('function'); | ||
}); | ||
|
||
describe('stripProjectRoot', () => { | ||
test('strips project root', () => { | ||
expect(stripProjectRoot( | ||
'/Users/test/git/my-app/', | ||
'/Users/test/git/my-app/src/index.js' | ||
)).toBe('src/index.js'); | ||
}); | ||
|
||
test('strips project root with no trailing slash', () => { | ||
expect(stripProjectRoot( | ||
'/Users/test/git/my-app', | ||
'/Users/test/git/my-app/src/index.js' | ||
)).toBe('src/index.js'); | ||
}); | ||
|
||
test(`wont strip project root when path is not within project root`, () => { | ||
expect(stripProjectRoot( | ||
'/Users/test/git/another-app', | ||
'/Users/test/git/my-app/src/index.js' | ||
)).toBe('/Users/test/git/my-app/src/index.js'); | ||
}); | ||
|
||
test('strips project root from node_moodules', () => { | ||
expect(stripProjectRoot( | ||
'/Users/test/git/my-app', | ||
'/Users/test/git/my-app/node_modules/some-module/lib/something.js' | ||
)).toBe('node_modules/some-module/lib/something.js'); | ||
}); | ||
|
||
test(`won't strip project root when path is absolute`, () => { | ||
expect(stripProjectRoot( | ||
'/Users/test/git/my-app', | ||
'src/index.js' | ||
)).toBe('src/index.js'); | ||
}); | ||
|
||
test('strips project root for Windows paths', () => { | ||
expect(stripProjectRoot( | ||
'C:/Users/test/git/my-app', | ||
'C:/Users/test/git/my-app/src/index.js' | ||
)).toBe('src\\index.js'); | ||
}); | ||
|
||
test('strips project root for Windows paths', () => { | ||
expect(stripProjectRoot( | ||
'C:\\Users\\test\\git\\my-app', | ||
'C:\\Users\\test\\git\\my-app\\src\\index.js' | ||
)).toBe('src\\index.js'); | ||
}); | ||
}); |