Skip to content

Commit

Permalink
langium: additional tests of UriUtils.relative() with windows paths
Browse files Browse the repository at this point in the history
  • Loading branch information
sailingKieler committed Feb 7, 2025
1 parent 23d4a14 commit 8c67d73
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/langium/test/utils/uri-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,36 @@ describe('URI Utils', () => {
expect(UriUtils.relative(from, to)).toBe('../d.txt');
});

test.skipIf(() => process.platform !== 'win32')('relative path in parent directory win32', () => {
const from = URI.file('c:\\a');
const to = URI.file('c:\\a\\c\\d.txt');
expect(UriUtils.relative(from, to)).toBe('../c/d.txt');
});

test('relative path in sub directory', () => {
const from = URI.file('/a');
const to = URI.file('/a/b/c.txt');
expect(UriUtils.relative(from, to)).toBe('b/c.txt');
});

test.skipIf(() => process.platform !== 'win32')('relative path in sub directory win32', () => {
const from = URI.file('c:\\a');
const to = URI.file('c:\\a\\c\\d.txt');
expect(UriUtils.relative(from, to)).toBe('../c/d.txt');
});

test('relative path in other directory', () => {
const from = URI.file('/a/b');
const to = URI.file('/a/c/d.txt');
expect(UriUtils.relative(from, to)).toBe('../c/d.txt');
});

test.skipIf(() => process.platform !== 'win32')('relative path in other directory win32', () => {
const from = URI.file('c:\\a\\b');
const to = URI.file('c:\\a\\c\\d.txt');
expect(UriUtils.relative(from, to)).toBe('../c/d.txt');
});

test('Equal uris are equal', () => {
const uri1 = 'file:///a/b';
const uri2 = 'file:///a/b';
Expand Down

0 comments on commit 8c67d73

Please sign in to comment.