-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from neumann-d/master
Feature: Allows cloning packages using the `file://` protocol. Closes #101. Thanks to @neumann-d!
- Loading branch information
Showing
2 changed files
with
117 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/** | ||
* @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md. | ||
*/ | ||
|
||
/* jshint mocha:true */ | ||
|
||
'use strict'; | ||
|
||
const expect = require( 'chai' ).expect; | ||
const parseRepositoryUrl = require( '../../lib/utils/parserepositoryurl' ); | ||
|
||
describe( 'utils', () => { | ||
describe( 'parseRepositoryUrl()', () => { | ||
it( 'returns "master" branch if "options.defaultBranch" was not specified', () => { | ||
const repository = parseRepositoryUrl( 'foo/bar', { | ||
urlTemplate: 'https://github.com/${ path }.git' | ||
} ); | ||
|
||
expect( repository ).to.deep.equal( { | ||
url: 'https://github.com/foo/bar.git', | ||
branch: 'master', | ||
directory: 'bar' | ||
} ); | ||
} ); | ||
|
||
it( 'allows modifying the branch using hash in "<organization>/<repositoryName>" template', () => { | ||
const repository = parseRepositoryUrl( 'foo/bar#stable', { | ||
urlTemplate: 'https://github.com/${ path }.git' | ||
} ); | ||
|
||
expect( repository ).to.deep.equal( { | ||
url: 'https://github.com/foo/bar.git', | ||
branch: 'stable', | ||
directory: 'bar' | ||
} ); | ||
} ); | ||
|
||
it( 'ignores "options.defaultBranch" if branch is defined in specified repository', () => { | ||
const repository = parseRepositoryUrl( 'foo/bar#stable', { | ||
urlTemplate: 'https://github.com/${ path }.git', | ||
defaultBranch: 'master' | ||
} ); | ||
|
||
expect( repository ).to.deep.equal( { | ||
url: 'https://github.com/foo/bar.git', | ||
branch: 'stable', | ||
directory: 'bar' | ||
} ); | ||
} ); | ||
|
||
it( 'extracts all parameters basing on specified "http" URL', () => { | ||
const repository = parseRepositoryUrl( 'http://github.com/foo/bar.git' ); | ||
|
||
expect( repository ).to.deep.equal( { | ||
url: 'http://github.com/foo/bar.git', | ||
branch: 'master', | ||
directory: 'bar' | ||
} ); | ||
} ); | ||
|
||
it( 'extracts all parameters basing on specified "https" URL', () => { | ||
const repository = parseRepositoryUrl( 'https://github.com/foo/bar.git' ); | ||
|
||
expect( repository ).to.deep.equal( { | ||
url: 'https://github.com/foo/bar.git', | ||
branch: 'master', | ||
directory: 'bar' | ||
} ); | ||
} ); | ||
|
||
it( 'extracts all parameters basing on specified "file" (Unix path)', () => { | ||
const repository = parseRepositoryUrl( 'file:///Users/Workspace/Projects/foo/bar' ); | ||
|
||
expect( repository ).to.deep.equal( { | ||
url: 'file:///Users/Workspace/Projects/foo/bar', | ||
branch: 'master', | ||
directory: 'bar' | ||
} ); | ||
} ); | ||
|
||
it( 'extracts all parameters basing on specified "file" (Windows path)', () => { | ||
const repository = parseRepositoryUrl( 'file://C:/Users/Workspace/Projects/foo/bar' ); | ||
|
||
expect( repository ).to.deep.equal( { | ||
url: 'file://c/Users/Workspace/Projects/foo/bar', | ||
branch: 'master', | ||
directory: 'bar' | ||
} ); | ||
} ); | ||
|
||
it( 'extracts all parameters basing on specified "git" URL', () => { | ||
const repository = parseRepositoryUrl( 'git@github.com:foo/bar.git' ); | ||
|
||
expect( repository ).to.deep.equal( { | ||
url: 'git@github.com:foo/bar.git', | ||
branch: 'master', | ||
directory: 'bar' | ||
} ); | ||
} ); | ||
|
||
it( 'allows modifying the branch using hash in the URL', () => { | ||
const repository = parseRepositoryUrl( 'https://github.com/foo/bar.git#stable' ); | ||
|
||
expect( repository ).to.deep.equal( { | ||
url: 'https://github.com/foo/bar.git', | ||
branch: 'stable', | ||
directory: 'bar' | ||
} ); | ||
} ); | ||
} ); | ||
} ); |