diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-01-26 08:05:07 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-01-26 08:05:07 +0100 |
commit | d6b44cc149fd6889f77107bb365a68079811576f (patch) | |
tree | 09b2c33b4ff449a17255a236bf8ea8707c89f072 /test | |
parent | 0f0ec4cf3d4741290a29cebacb7b544bd18cde15 (diff) | |
download | gitbook-d6b44cc149fd6889f77107bb365a68079811576f.zip gitbook-d6b44cc149fd6889f77107bb365a68079811576f.tar.gz gitbook-d6b44cc149fd6889f77107bb365a68079811576f.tar.bz2 |
Add tests for parsing git url
Diffstat (limited to 'test')
-rw-r--r-- | test/git.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/git.js b/test/git.js new file mode 100644 index 0000000..2ac1eb9 --- /dev/null +++ b/test/git.js @@ -0,0 +1,32 @@ +var path = require('path'); +var _ = require('lodash'); +var assert = require('assert'); + +var fs = require("fs"); +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"); + assert(parts); + assert.equal(parts.host, "https://gist.github.com/69ea4542e4c8967d2fa7.git"); + assert.equal(parts.ref, "master"); + assert.equal(parts.filepath, "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"); + assert(parts); + assert.equal(parts.host, "https://gist.github.com/69ea4542e4c8967d2fa7.git"); + assert.equal(parts.ref, "0.1.2"); + assert.equal(parts.filepath, "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"); + assert(parts); + assert.equal(parts.host, "git@github.com"); + assert.equal(parts.ref, "e1594cde2c32e4ff48f6c4eff3d3d461743d74e1"); + assert.equal(parts.filepath, "directory/README.md"); + }); +}); |