From c256dfdca7a4fe141c3a5ed0d7dfc21c17264327 Mon Sep 17 00:00:00 2001 From: ggdaltoso Date: Thu, 25 Aug 2022 14:38:15 -0300 Subject: [PATCH] feat: add `edit` filepathtype support --- test/index.js | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/test/index.js b/test/index.js index ec37c09..4968b9c 100644 --- a/test/index.js +++ b/test/index.js @@ -396,25 +396,21 @@ tester.describe("parse urls", test => { test.expect(res.filepathtype).toBe("blob"); test.expect(res.filepath).toBe("test/index.js"); - res = gitUrlParse("https://gitlab.com/a/b/c/d/blob/master/test/index.js"); - test.expect(res.protocol).toBe("https"); - test.expect(res.source).toBe("gitlab.com"); - test.expect(res.owner).toBe("a/b/c"); - test.expect(res.name).toBe("d"); - test.expect(res.href).toBe("https://gitlab.com/a/b/c/d/blob/master/test/index.js"); - test.expect(res.ref).toBe("master"); - test.expect(res.filepathtype).toBe("blob"); - test.expect(res.filepath).toBe("test/index.js"); - - res = gitUrlParse("https://gitlab.com/a/b/c/d/-/blob/master/test/index.js"); - test.expect(res.protocol).toBe("https"); - test.expect(res.source).toBe("gitlab.com"); - test.expect(res.owner).toBe("a/b/c"); - test.expect(res.name).toBe("d"); - test.expect(res.href).toBe("https://gitlab.com/a/b/c/d/-/blob/master/test/index.js"); - test.expect(res.ref).toBe("master"); - test.expect(res.filepathtype).toBe("blob"); - test.expect(res.filepath).toBe("test/index.js"); + function testForFilepathtypeURL(type) { + res = gitUrlParse(`https://gitlab.com/a/b/c/d/${type}/master/test/index.js`); + + test.expect(res.protocol).toBe("https"); + test.expect(res.source).toBe("gitlab.com"); + test.expect(res.owner).toBe("a/b/c"); + test.expect(res.name).toBe("d"); + test.expect(res.href).toBe(`https://gitlab.com/a/b/c/d/${type}/master/test/index.js`); + test.expect(res.ref).toBe("master"); + test.expect(res.filepathtype).toBe(type); + test.expect(res.filepath).toBe("test/index.js"); + } + + // execute for raw, src, blob, and tree + ['blob', 'raw', 'blob', 'tree', 'edit'].forEach(testForFilepathtypeURL); }); // shorthand urls