|
| 1 | +describe('prepareLinks', function() { |
| 2 | + var grunt = require('grunt'); |
| 3 | + var prepareLinks = require('../tasks/grunt-ngdocs.js')(grunt).prepareLinks; |
| 4 | + |
| 5 | + it('should handel github https url', function() { |
| 6 | + var pkg = {repository: {url: 'https://github.com/owner/name'}}; |
| 7 | + var opts = {sourceEdit:true, editLink: true}; |
| 8 | + prepareLinks(pkg, opts); |
| 9 | + expect(opts.editLink('test.js')).toEqual('https://github.com/owner/name/edit/master/test.js'); |
| 10 | + }); |
| 11 | + |
| 12 | + it('should handel github https url with .git suffix', function() { |
| 13 | + var pkg = {repository: {url: 'https://github.com/owner/name.git'}}; |
| 14 | + var opts = {sourceEdit:true, editLink: true}; |
| 15 | + prepareLinks(pkg, opts); |
| 16 | + expect(opts.editLink('test.js')).toEqual('https://github.com/owner/name/edit/master/test.js'); |
| 17 | + }); |
| 18 | + |
| 19 | + it('should handel github https url with .git and path suffix', function() { |
| 20 | + var pkg = {repository: {url: 'https://github.com/owner/name.git/#123456/'}}; |
| 21 | + var opts = {sourceEdit:true, editLink: true}; |
| 22 | + prepareLinks(pkg, opts); |
| 23 | + expect(opts.editLink('test.js')).toEqual('https://github.com/owner/name/edit/master/test.js'); |
| 24 | + }); |
| 25 | + |
| 26 | + it('should handel git@github url', function() { |
| 27 | + var pkg = {repository: {url: '[email protected]:owner/name'}}; |
| 28 | + var opts = {sourceEdit:true, editLink: true}; |
| 29 | + prepareLinks(pkg, opts); |
| 30 | + expect(opts.editLink('test.js')).toEqual('https://github.com/owner/name/edit/master/test.js'); |
| 31 | + }); |
| 32 | + |
| 33 | + it('should handel git@github url with .git suffix', function() { |
| 34 | + var pkg = {repository: {url: '[email protected]:owner/name.git'}}; |
| 35 | + var opts = {sourceEdit:true, editLink: true}; |
| 36 | + prepareLinks(pkg, opts); |
| 37 | + expect(opts.editLink('test.js')).toEqual('https://github.com/owner/name/edit/master/test.js'); |
| 38 | + }); |
| 39 | +}); |
0 commit comments