1 var assert = require("assert")
2 var getUrl = require("../")
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)
10 it("returns null if it does not match", function () {
11 var url = getUrl("package")
12 assert.deepEqual(null, url)
15 it("returns null if no repo/user was given", function () {
17 assert.deepEqual(null, url)
20 it("returns null for something that's already a URI", function () {
21 var url = getUrl("file:../relative")
22 assert.deepEqual(null, url)
25 it("works with .", function () {
26 var url = getUrl("component/.download.er.js.")
27 assert.equal("https://github.com/component/.download.er.js.", url)
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)
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)
40 it("can handle branches with #", function () {
42 "component/entejs#1c3e1fe71640b4b477f04d947bd53c473799b277")
44 assert.equal("https://github.com/component/entejs#1c3e1fe71640b" +
45 "4b477f04d947bd53c473799b277", url)
48 it("can handle branches with slashes", function () {
50 "component/entejs#some/branch/name")
52 assert.equal("https://github.com/component/entejs#some/branch/name", url)
55 describe("browser mode", function () {
56 it("is able to return urls for branches", function () {
58 "component/entejs#1c3e1fe71640b4b477f04d947bd53c473799b277", true)
60 assert.equal("https://github.com/component/entejs/tree/1c3e1fe71640b" +
61 "4b477f04d947bd53c473799b277", url)
63 it("is able to return urls without a branch for the browser", function () {
65 "component/entejs", true)
67 assert.equal("https://github.com/component/entejs", url)