]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/github-url-from-username-repo/test/index.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / node_modules / github-url-from-username-repo / test / index.js
1 var assert = require("assert")
2 var getUrl = require("../")
3
4 describe("github url from username/repo", function () {
5   it("returns a github url for the username/repo", function () {
6     var url = getUrl("visionmedia/express")
7     assert.equal("https://github.com/visionmedia/express", url)
8   })
9
10   it("returns null if it does not match", function () {
11     var url = getUrl("package")
12     assert.deepEqual(null, url)
13   })
14
15   it("returns null if no repo/user was given", function () {
16     var url = getUrl()
17     assert.deepEqual(null, url)
18   })
19
20   it("returns null for something that's already a URI", function () {
21     var url = getUrl("file:../relative")
22     assert.deepEqual(null, url)
23   })
24
25   it("works with .", function () {
26     var url = getUrl("component/.download.er.js.")
27     assert.equal("https://github.com/component/.download.er.js.", url)
28   })
29
30   it("works with . in the beginning", function () {
31     var url = getUrl("component/.downloader.js")
32     assert.equal("https://github.com/component/.downloader.js", url)
33   })
34
35   it("works with -", function () {
36     var url = getUrl("component/-dow-nloader.j-s")
37     assert.equal("https://github.com/component/-dow-nloader.j-s", url)
38   })
39
40   it("can handle branches with #", function () {
41     var url = getUrl(
42       "component/entejs#1c3e1fe71640b4b477f04d947bd53c473799b277")
43
44     assert.equal("https://github.com/component/entejs#1c3e1fe71640b" +
45       "4b477f04d947bd53c473799b277", url)
46   })
47
48   it("can handle branches with slashes", function () {
49     var url = getUrl(
50       "component/entejs#some/branch/name")
51
52     assert.equal("https://github.com/component/entejs#some/branch/name", url)
53   })
54
55   describe("browser mode", function () {
56     it("is able to return urls for branches", function () {
57       var url = getUrl(
58         "component/entejs#1c3e1fe71640b4b477f04d947bd53c473799b277", true)
59
60       assert.equal("https://github.com/component/entejs/tree/1c3e1fe71640b" +
61         "4b477f04d947bd53c473799b277", url)
62     })
63     it("is able to return urls without a branch for the browser", function () {
64       var url = getUrl(
65         "component/entejs", true)
66
67       assert.equal("https://github.com/component/entejs", url)
68     })
69   })
70 })