Skip to content

Commit

Permalink
Merge branch 'custom-ssh-user-tests' of github.com:privatenumber/git-…
Browse files Browse the repository at this point in the history
…url-parse into new-version
  • Loading branch information
IonicaBizau committed Aug 30, 2022
2 parents 32ed275 + 7cce252 commit 4e3b1cc
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ const gitUrlParse = require("..")

// Constants
const URLS = {
ssh: "git@github.com:42IonicaBizau/git-url-parse"
ssh: "custom-user@github.com:42IonicaBizau/git-url-parse"
, https: "https://github.com/42IonicaBizau/git-url-parse"
, ftp: "ftp://github.com/42IonicaBizau/git-url-parse"
, ftps: "ftps://github.com/42IonicaBizau/git-url-parse"
, gitSsh: "git+ssh://git@github.com/42IonicaBizau/git-url-parse"
, gitSsh: "git+ssh://custom-user@github.com/42IonicaBizau/git-url-parse"
, ref: "https://github.com/42IonicaBizau/git-url-parse/blob/master/test/index.js"
, shorthand: "42IonicaBizau/git-url-parse"
, commit: "https://github.com/42IonicaBizau/git-url-parse/commit/9c6443245ace92d237b7b274d4606a616e071c4e"
};

const gitUser = (url) => url.replace('custom-user@', 'git@');

tester.describe("parse urls", test => {

// SSH urls
Expand Down Expand Up @@ -45,8 +47,8 @@ tester.describe("parse urls", test => {
test.expect(res.name).toBe("git-url-parse");
test.expect(res.href).toBe(URLS.ftp);
test.expect(res.toString("https")).toBe(URLS.https);
test.expect(res.toString("git+ssh")).toBe(URLS.gitSsh);
test.expect(res.toString("ssh")).toBe(URLS.ssh);
test.expect(res.toString("git+ssh")).toBe(gitUser(URLS.gitSsh));
test.expect(res.toString("ssh")).toBe(gitUser(URLS.ssh));
});

// FTPS urls
Expand All @@ -58,8 +60,8 @@ tester.describe("parse urls", test => {
test.expect(res.name).toBe("git-url-parse");
test.expect(res.href).toBe(URLS.ftps);
test.expect(res.toString("https")).toBe(URLS.https);
test.expect(res.toString("git+ssh")).toBe(URLS.gitSsh);
test.expect(res.toString("ssh")).toBe(URLS.ssh);
test.expect(res.toString("git+ssh")).toBe(gitUser(URLS.gitSsh));
test.expect(res.toString("ssh")).toBe(gitUser(URLS.ssh));
});

// HTTPS urls
Expand All @@ -71,8 +73,8 @@ tester.describe("parse urls", test => {
test.expect(res.name).toBe("git-url-parse");
test.expect(res.href).toBe(URLS.https);
test.expect(res.toString("https")).toBe(URLS.https);
test.expect(res.toString("git+ssh")).toBe(URLS.gitSsh);
test.expect(res.toString("ssh")).toBe(URLS.ssh);
test.expect(res.toString("git+ssh")).toBe(gitUser(URLS.gitSsh));
test.expect(res.toString("ssh")).toBe(gitUser(URLS.ssh));
});

// HTTPS with ending slash
Expand All @@ -83,8 +85,8 @@ tester.describe("parse urls", test => {
test.expect(res.owner).toBe("42IonicaBizau");
test.expect(res.name).toBe("git-url-parse");
test.expect(res.toString("https")).toBe(URLS.https);
test.expect(res.toString("git+ssh")).toBe(URLS.gitSsh);
test.expect(res.toString("ssh")).toBe(URLS.ssh);
test.expect(res.toString("git+ssh")).toBe(gitUser(URLS.gitSsh));
test.expect(res.toString("ssh")).toBe(gitUser(URLS.ssh));
});

// git+ssh protocol
Expand Down

0 comments on commit 4e3b1cc

Please sign in to comment.