mirror of
https://github.com/documentationjs/documentation.git
synced 2026-01-18 14:17:30 +00:00
* Fixed find_git test for windows platform. * Fixed github test on windows platform. * Fixed bin tests which are executed process from node.js * On windows platform uses DOUBLE EXCLAMATION MARK instead of WARNING SIGN.
87 lines
1.7 KiB
JavaScript
87 lines
1.7 KiB
JavaScript
'use strict';
|
|
|
|
/* eslint no-unused-vars: 0 */
|
|
|
|
var test = require('tap').test,
|
|
mock = require('mock-fs'),
|
|
path = require('path'),
|
|
mockRepo = require('./git/mock_repo'),
|
|
parse = require('../../lib/parsers/javascript'),
|
|
github = require('../../lib/github');
|
|
|
|
function toComment(fn, filename) {
|
|
return parse({
|
|
file: filename,
|
|
source: fn instanceof Function ? '(' + fn.toString() + ')' : fn
|
|
}, {}).map(github);
|
|
}
|
|
|
|
const root = path.parse(__dirname).root;
|
|
|
|
function evaluate(fn) {
|
|
return toComment(fn, root + path.join('my', 'repository', 'path', 'index.js'));
|
|
}
|
|
|
|
test('github', function (t) {
|
|
|
|
mock(mockRepo.master);
|
|
|
|
t.deepEqual(evaluate(function () {
|
|
/**
|
|
* get one
|
|
* @returns {number} one
|
|
*/
|
|
function getOne() {
|
|
return 1;
|
|
}
|
|
})[0].context.github, {
|
|
path: 'index.js',
|
|
url: 'https://github.com/foo/bar/blob/this_is_the_sha/index.js#L6-L8'
|
|
}, 'gets github url');
|
|
|
|
mock.restore();
|
|
|
|
t.end();
|
|
});
|
|
|
|
test('malformed repository', function (t) {
|
|
|
|
mock(mockRepo.malformed);
|
|
|
|
t.equal(evaluate(function () {
|
|
/**
|
|
* get one
|
|
* @returns {number} one
|
|
*/
|
|
function getOne() {
|
|
return 1;
|
|
}
|
|
})[0].context.github, undefined, 'does not crash');
|
|
|
|
mock.restore();
|
|
|
|
t.end();
|
|
});
|
|
|
|
test('enterprise repository', function (t) {
|
|
|
|
mock(mockRepo.enterprise);
|
|
|
|
t.deepEqual(evaluate(function () {
|
|
/**
|
|
* get one
|
|
* @returns {number} one
|
|
*/
|
|
function getOne() {
|
|
return 1;
|
|
}
|
|
})[0].context.github, {
|
|
path: 'index.js',
|
|
url: 'https://github.enterprise.com/foo/bar/blob/this_is_the_sha/index.js#L6-L8'
|
|
}, 'gets github enterprise url');
|
|
|
|
mock.restore();
|
|
|
|
t.end();
|
|
});
|