Skip to content

Commit 4a985ce

Browse files
langium: additional tests of UriUtils.relative() with windows paths (#1805)
* they're executed on windows only and skipped for all other platforms, because of https://github.com/microsoft/vscode-uri/blob/edfdccd976efaf4bb8fdeca87e97c47257721729/src/uri.ts#L309-L311
1 parent 87cbe24 commit 4a985ce

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

packages/langium/test/utils/uri-utils.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,36 @@ describe('URI Utils', () => {
2121
expect(UriUtils.relative(from, to)).toBe('../d.txt');
2222
});
2323

24+
test.skipIf(process.platform !== 'win32')('relative path in parent directory win32', () => {
25+
const from = URI.file('c:\\a\\b');
26+
const to = URI.file('c:\\a\\d.txt');
27+
expect(UriUtils.relative(from, to)).toBe('../d.txt');
28+
});
29+
2430
test('relative path in sub directory', () => {
2531
const from = URI.file('/a');
2632
const to = URI.file('/a/b/c.txt');
2733
expect(UriUtils.relative(from, to)).toBe('b/c.txt');
2834
});
2935

36+
test.skipIf(process.platform !== 'win32')('relative path in sub directory win32', () => {
37+
const from = URI.file('c:\\a');
38+
const to = URI.file('c:\\a\\b\\c.txt');
39+
expect(UriUtils.relative(from, to)).toBe('b/c.txt');
40+
});
41+
3042
test('relative path in other directory', () => {
3143
const from = URI.file('/a/b');
3244
const to = URI.file('/a/c/d.txt');
3345
expect(UriUtils.relative(from, to)).toBe('../c/d.txt');
3446
});
3547

48+
test.skipIf(process.platform !== 'win32')('relative path in other directory win32', () => {
49+
const from = URI.file('c:\\a\\b');
50+
const to = URI.file('c:\\a\\c\\d.txt');
51+
expect(UriUtils.relative(from, to)).toBe('../c/d.txt');
52+
});
53+
3654
test('Equal uris are equal', () => {
3755
const uri1 = 'file:///a/b';
3856
const uri2 = 'file:///a/b';

0 commit comments

Comments
 (0)