summaryrefslogtreecommitdiffstats
path: root/test/git.js
blob: 6fd6b41c8566a350d1238178b4900d92aaa1d986 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
var should = require("should");
var git = require("../lib/utils/git");

describe("GIT parser and getter", function () {
    it("should correctly parse an https url", function() {
        var parts = git.parseUrl("git+https://gist.github.com/69ea4542e4c8967d2fa7.git/test.md");

        should.exist(parts);
        parts.host.should.be.equal("https://gist.github.com/69ea4542e4c8967d2fa7.git");
        parts.ref.should.be.equal("master");
        parts.filepath.should.be.equal("test.md");
    });

    it("should correctly parse an https url with a reference", function() {
        var parts = git.parseUrl("git+https://gist.github.com/69ea4542e4c8967d2fa7.git/test.md#0.1.2");

        should.exist(parts);
        parts.host.should.be.equal("https://gist.github.com/69ea4542e4c8967d2fa7.git");
        parts.ref.should.be.equal("0.1.2");
        parts.filepath.should.be.equal("test.md");
    });

    it("should correctly parse an ssh url", function() {
        var parts = git.parseUrl("git+git@github.com:GitbookIO/gitbook.git/directory/README.md#e1594cde2c32e4ff48f6c4eff3d3d461743d74e1");

        should.exist(parts);
        parts.host.should.be.equal("git@github.com:GitbookIO/gitbook.git");
        parts.ref.should.be.equal("e1594cde2c32e4ff48f6c4eff3d3d461743d74e1");
        parts.filepath.should.be.equal("directory/README.md");
    });
});