Welcome to mirror list, hosted at ThFree Co, Russian Federation.

index.js « test « github-url-from-username-repo « node_modules - github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 10fe3a34cc37c387406367623c5dabf731ac7988 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
var assert = require("assert")
var getUrl = require("../")

describe("github url from username/repo", function () {
  it("returns a github url for the username/repo", function () {
    var url = getUrl("visionmedia/express")
    assert.equal("https://github.com/visionmedia/express", url)
  })

  it("returns null if it does not match", function () {
    var url = getUrl("package")
    assert.deepEqual(null, url)
  })

  it("returns null if no repo/user was given", function () {
    var url = getUrl()
    assert.deepEqual(null, url)
  })

  it("returns null for something that's already a URI", function () {
    var url = getUrl("file:../relative")
    assert.deepEqual(null, url)
  })

  it("works with .", function () {
    var url = getUrl("component/.download.er.js.")
    assert.equal("https://github.com/component/.download.er.js.", url)
  })

  it("works with . in the beginning", function () {
    var url = getUrl("component/.downloader.js")
    assert.equal("https://github.com/component/.downloader.js", url)
  })

  it("works with -", function () {
    var url = getUrl("component/-dow-nloader.j-s")
    assert.equal("https://github.com/component/-dow-nloader.j-s", url)
  })

  it("can handle branches with #", function () {
    var url = getUrl(
      "component/entejs#1c3e1fe71640b4b477f04d947bd53c473799b277")

    assert.equal("https://github.com/component/entejs#1c3e1fe71640b" +
      "4b477f04d947bd53c473799b277", url)
  })

  it("can handle branches with slashes", function () {
    var url = getUrl(
      "component/entejs#some/branch/name")

    assert.equal("https://github.com/component/entejs#some/branch/name", url)
  })

  describe("browser mode", function () {
    it("is able to return urls for branches", function () {
      var url = getUrl(
        "component/entejs#1c3e1fe71640b4b477f04d947bd53c473799b277", true)

      assert.equal("https://github.com/component/entejs/tree/1c3e1fe71640b" +
        "4b477f04d947bd53c473799b277", url)
    })
    it("is able to return urls without a branch for the browser", function () {
      var url = getUrl(
        "component/entejs", true)

      assert.equal("https://github.com/component/entejs", url)
    })
  })
})