diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-03-24 14:44:07 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-03-24 14:44:07 +0100 |
commit | 303fc992d46bc76801376a4469c26a3c61c370d7 (patch) | |
tree | e9400fe0e1150509fa9a3d328ce8ae65f330e939 /test/git.js | |
parent | 4b7797f61b969b6d7bd3b5cfe1f9ff0f22b57ae7 (diff) | |
download | gitbook-303fc992d46bc76801376a4469c26a3c61c370d7.zip gitbook-303fc992d46bc76801376a4469c26a3c61c370d7.tar.gz gitbook-303fc992d46bc76801376a4469c26a3c61c370d7.tar.bz2 |
Add test for git url parsing
Diffstat (limited to 'test/git.js')
-rw-r--r-- | test/git.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/git.js b/test/git.js new file mode 100644 index 0000000..f03bec2 --- /dev/null +++ b/test/git.js @@ -0,0 +1,31 @@ +var should = require('should'); +var git = require('../lib/utils/git'); + +describe('GIT parser and getter', function () { + it('should correctly parse an https url', function() { + var parts = git.parseUrl("git+https://gist.github.com/69ea4542e4c8967d2fa7.git/test.md"); + + should.exist(parts); + parts.host.should.be.equal("https://gist.github.com/69ea4542e4c8967d2fa7.git"); + parts.ref.should.be.equal("master"); + parts.filepath.should.be.equal("test.md"); + }); + + it('should correctly parse an https url with a reference', function() { + var parts = git.parseUrl("git+https://gist.github.com/69ea4542e4c8967d2fa7.git/test.md#0.1.2"); + + should.exist(parts); + parts.host.should.be.equal("https://gist.github.com/69ea4542e4c8967d2fa7.git"); + parts.ref.should.be.equal("0.1.2"); + parts.filepath.should.be.equal("test.md"); + }); + + it('should correctly parse an ssh url', function() { + var parts = git.parseUrl("git+git@github.com:GitbookIO/gitbook.git/directory/README.md#e1594cde2c32e4ff48f6c4eff3d3d461743d74e1"); + + should.exist(parts); + parts.host.should.be.equal("git@github.com:GitbookIO/gitbook.git"); + parts.ref.should.be.equal("e1594cde2c32e4ff48f6c4eff3d3d461743d74e1"); + parts.filepath.should.be.equal("directory/README.md"); + }); +}); |