diff options
author | Samy Pesse <samypesse@gmail.com> | 2016-04-30 22:06:16 +0200 |
---|---|---|
committer | Samy Pesse <samypesse@gmail.com> | 2016-04-30 22:06:16 +0200 |
commit | c1d53ec11fbe085932df911bda5686b7bf671f53 (patch) | |
tree | 97ae6db641eb79ec9b061af136a0b2e3c549db55 /test/git.js | |
parent | 36b49c66c6b75515bc84dd678fd52121a313e8d2 (diff) | |
download | gitbook-c1d53ec11fbe085932df911bda5686b7bf671f53.zip gitbook-c1d53ec11fbe085932df911bda5686b7bf671f53.tar.gz gitbook-c1d53ec11fbe085932df911bda5686b7bf671f53.tar.bz2 |
Switch parsers to a model
Diffstat (limited to 'test/git.js')
-rw-r--r-- | test/git.js | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/test/git.js b/test/git.js deleted file mode 100644 index 9fd7490..0000000 --- a/test/git.js +++ /dev/null @@ -1,61 +0,0 @@ -var should = require('should'); -var path = require('path'); -var os = require('os'); - -var Git = require('../lib/utils/git'); - -describe('Git', function() { - - describe('URL parsing', function() { - - it('should correctly validate git urls', function() { - // HTTPS - Git.isUrl('git+https://github.com/Hello/world.git').should.be.ok(); - - // SSH - Git.isUrl('git+git@github.com:GitbookIO/gitbook.git/directory/README.md#e1594cde2c32e4ff48f6c4eff3d3d461743d74e1').should.be.ok; - - // Non valid - Git.isUrl('https://github.com/Hello/world.git').should.not.be.ok(); - Git.isUrl('README.md').should.not.be.ok(); - }); - - it('should parse HTTPS urls', 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'); - should(parts.ref).be.equal(null); - parts.filepath.should.be.equal('test.md'); - }); - - it('should parse HTTPS urls with a reference', function() { - var parts = Git.parseUrl('git+https://gist.github.com/69ea4542e4c8967d2fa7.git/test.md#1.0.0'); - - should.exist(parts); - parts.host.should.be.equal('https://gist.github.com/69ea4542e4c8967d2fa7.git'); - parts.ref.should.be.equal('1.0.0'); - parts.filepath.should.be.equal('test.md'); - }); - - it('should parse SSH urls', 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'); - }); - }); - - describe('Cloning and resolving', function() { - it('should clone an HTTPS url', function() { - var git = new Git(path.join(os.tmpdir(), 'test-git-'+Date.now())); - return git.resolve('git+https://gist.github.com/69ea4542e4c8967d2fa7.git/test.md') - .then(function(filename) { - path.extname(filename).should.equal('.md'); - }); - }); - }); - -}); |