2013-10-25 00:21:59 +08:00
|
|
|
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")
|
2014-08-01 00:05:30 +08:00
|
|
|
assert.equal("https://github.com/visionmedia/express", url)
|
2013-10-25 00:21:59 +08:00
|
|
|
})
|
2014-05-02 02:09:00 +08:00
|
|
|
|
2013-10-25 00:21:59 +08:00
|
|
|
it("returns null if it does not match", function () {
|
|
|
|
var url = getUrl("package")
|
|
|
|
assert.deepEqual(null, url)
|
|
|
|
})
|
2014-05-02 02:09:00 +08:00
|
|
|
|
|
|
|
it("returns null if no repo/user was given", function () {
|
2013-10-25 00:21:59 +08:00
|
|
|
var url = getUrl()
|
2014-05-02 02:09:00 +08:00
|
|
|
assert.deepEqual(null, url)
|
|
|
|
})
|
|
|
|
|
|
|
|
it("works with .", function () {
|
2014-09-17 06:38:50 +08:00
|
|
|
var url = getUrl("component/.download.er.js.")
|
|
|
|
assert.equal("https://github.com/component/.download.er.js.", url)
|
2014-05-02 02:09:00 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
it("works with . in the beginning", function () {
|
|
|
|
var url = getUrl("component/.downloader.js")
|
2014-08-01 00:05:30 +08:00
|
|
|
assert.equal("https://github.com/component/.downloader.js", url)
|
2014-05-02 02:09:00 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
it("works with -", function () {
|
|
|
|
var url = getUrl("component/-dow-nloader.j-s")
|
2014-08-01 00:05:30 +08:00
|
|
|
assert.equal("https://github.com/component/-dow-nloader.j-s", url)
|
2013-10-25 00:21:59 +08:00
|
|
|
})
|
2014-09-17 06:38:50 +08:00
|
|
|
|
|
|
|
it("can handle branches with #", function () {
|
|
|
|
var url = getUrl(
|
|
|
|
"component/entejs#1c3e1fe71640b4b477f04d947bd53c473799b277")
|
|
|
|
|
|
|
|
assert.equal("https://github.com/component/entejs#1c3e1fe71640b" +
|
|
|
|
"4b477f04d947bd53c473799b277", 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)
|
|
|
|
})
|
|
|
|
})
|
2014-05-02 02:09:00 +08:00
|
|
|
})
|