Cast path variables to DevToolsPath types rather than function argument

Bug: 1253323
Change-Id: I8f044f1f37e99ac4a42fab5db99782e549df72ae
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3298818
Reviewed-by: Victor Porof <victorporof@chromium.org>
Commit-Queue: Kateryna Prokopenko <kprokopenko@chromium.org>
This commit is contained in:
Kateryna Prokopenko
2021-11-25 08:21:35 +00:00
committed by Devtools-frontend LUCI CQ
parent e5f0f5a6c4
commit 6905046d6f
@@ -70,32 +70,32 @@ describe('Parsed URL', () => {
});
it('converts platform path to a URL that does not start with "file://"', () => {
const platformPathTest = 'usr/lib';
const convertedUrl = ParsedURL.rawPathToUrlString(platformPathTest as Platform.DevToolsPath.RawPathString);
const platformPathTest = 'usr/lib' as Platform.DevToolsPath.RawPathString;
const convertedUrl = ParsedURL.rawPathToUrlString(platformPathTest);
assert.strictEqual(convertedUrl, 'file:///usr/lib', 'URL was not converted correctly');
});
it('converts platform path to a URL that does not start with "file://" but starts with a slash ("/")', () => {
const platformPathTest = '/usr/lib';
const convertedUrl = ParsedURL.rawPathToUrlString(platformPathTest as Platform.DevToolsPath.RawPathString);
const platformPathTest = '/usr/lib' as Platform.DevToolsPath.RawPathString;
const convertedUrl = ParsedURL.rawPathToUrlString(platformPathTest);
assert.strictEqual(convertedUrl, 'file:///usr/lib', 'URL was not converted correctly');
});
it('converts platform path to a URL that starts with "file://"', () => {
const platformPathTest = 'file://usr/lib';
const convertedUrl = ParsedURL.rawPathToUrlString(platformPathTest as Platform.DevToolsPath.RawPathString);
const platformPathTest = 'file://usr/lib' as Platform.DevToolsPath.RawPathString;
const convertedUrl = ParsedURL.rawPathToUrlString(platformPathTest);
assert.strictEqual(convertedUrl, 'file://usr/lib', 'URL was not converted correctly');
});
it('converts path that starts with "file://" to a platform path', () => {
const pathTest = 'file://usr/lib';
const convertedPath = ParsedURL.capFilePrefix(pathTest as Platform.DevToolsPath.UrlString);
const pathTest = 'file://usr/lib' as Platform.DevToolsPath.UrlString;
const convertedPath = ParsedURL.capFilePrefix(pathTest);
assert.strictEqual(convertedPath, 'usr/lib', 'URL was not converted successfully');
});
it('converts path that starts with "file:///" to a platform path on Windows', () => {
const pathTest = 'file:///usr/lib';
const convertedPath = ParsedURL.capFilePrefix(pathTest as Platform.DevToolsPath.UrlString, true);
const pathTest = 'file:///usr/lib' as Platform.DevToolsPath.UrlString;
const convertedPath = ParsedURL.capFilePrefix(pathTest, true);
assert.strictEqual(convertedPath, 'usr\\lib', 'URL was not converted successfully');
});