-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Windows tests to cover normalizedPath
- Loading branch information
Showing
4 changed files
with
45 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,46 @@ | ||
import { expect, test } from 'vitest'; | ||
import { normalizePath } from '../src/normalize.path'; | ||
import { resolve } from 'path'; | ||
|
||
test('should normalize path ending with slash', () => { | ||
const path = '/path/to/folder/'; | ||
const normalizedPath: string = normalizePath(path); | ||
expect(normalizedPath).to.equal('/path/to/folder/'); | ||
if (process.platform === 'win32') { | ||
expect(normalizedPath).to.equal('C:\\path\\to\\folder\\'); | ||
Check failure on line 8 in __tests__/normalize.test.ts GitHub Actions / windows (18)__tests__/normalize.test.ts > should normalize path ending with slash
Check failure on line 8 in __tests__/normalize.test.ts GitHub Actions / windows (20)__tests__/normalize.test.ts > should normalize path ending with slash
|
||
} else { | ||
expect(normalizedPath).to.equal('/path/to/folder/'); | ||
} | ||
}); | ||
|
||
test('should normalize path without ending slash', () => { | ||
const path = '/path/to/folder'; | ||
const normalizedPath: string = normalizePath(path); | ||
expect(normalizedPath).to.equal('/path/to/folder/'); | ||
if (process.platform === 'win32') { | ||
expect(normalizedPath).to.equal('C:\\path\\to\\folder\\'); | ||
Check failure on line 18 in __tests__/normalize.test.ts GitHub Actions / windows (18)__tests__/normalize.test.ts > should normalize path without ending slash
Check failure on line 18 in __tests__/normalize.test.ts GitHub Actions / windows (20)__tests__/normalize.test.ts > should normalize path without ending slash
|
||
} else { | ||
expect(normalizedPath).to.equal('/path/to/folder/'); | ||
} | ||
}); | ||
|
||
test('should normalize empty path', () => { | ||
const path = ''; | ||
const normalizedPath: string = normalizePath(path); | ||
expect(normalizedPath).to.equal(`${resolve('./')}/`); | ||
expect(() => normalizePath(path)).to.throw('Path cannot be empty'); | ||
}); | ||
|
||
test('should normalize root path', () => { | ||
const path = '/'; | ||
const normalizedPath: string = normalizePath(path); | ||
expect(normalizedPath).to.equal('/'); | ||
|
||
if (process.platform === 'win32') { | ||
expect(normalizedPath).to.equal('C:\\'); | ||
Check failure on line 34 in __tests__/normalize.test.ts GitHub Actions / windows (18)__tests__/normalize.test.ts > should normalize root path
|
||
} else { | ||
expect(normalizedPath).to.equal('/'); | ||
} | ||
}); | ||
|
||
test('should append trailing backslash if path ends with backslash on Windows systems', () => { | ||
const path = 'C:\\Users\\test\\Projects\\pdf-to-png-converter\\src\\'; | ||
const normalizedPath = normalizePath(path); | ||
expect(normalizedPath).to.equal('C:\\Users\\test\\Projects\\pdf-to-png-converter\\src\\'); | ||
}); | ||
if (process.platform === 'win32') { | ||
test('should append trailing backslash if path ends with backslash on Windows systems', () => { | ||
const path = 'C:\\Windows\\'; | ||
const normalizedPath = normalizePath(path); | ||
expect(normalizedPath).to.equal('C:\\Windows\\'); | ||
}); | ||
} |
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