mirror of
https://github.com/documentationjs/documentation.git
synced 2025-12-08 18:23:43 +00:00
BREAKING CHANGE: This moves documentation.js to Babel 7. From now on, documentation.js will only support Babel 7: please stick to older releases if you need to support Babel 6. Additionally, this work temporarily disables support for following dynamic imports.
114 lines
2.2 KiB
JavaScript
114 lines
2.2 KiB
JavaScript
/* eslint no-unused-vars: 0 */
|
|
|
|
const mock = require('mock-fs');
|
|
const path = require('path');
|
|
const mockRepo = require('../utils').mockRepo;
|
|
const parse = require('../../src/parsers/javascript');
|
|
const github = require('../../src/github');
|
|
|
|
// mock-fs is causing some unusual side effects with jest-resolve
|
|
// not being able to resolve modules so we've disabled these tests
|
|
// for now.
|
|
|
|
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')
|
|
);
|
|
}
|
|
|
|
afterEach(function() {
|
|
mock.restore();
|
|
});
|
|
|
|
test.skip('github', function() {
|
|
mock(mockRepo.master);
|
|
|
|
expect(
|
|
evaluate(function() {
|
|
/**
|
|
* get one
|
|
* @returns {number} one
|
|
*/
|
|
function getOne() {
|
|
return 1;
|
|
}
|
|
})[0].context.github
|
|
).toEqual({
|
|
path: 'index.js',
|
|
url: 'https://github.com/foo/bar/blob/this_is_the_sha/index.js#L6-L8'
|
|
});
|
|
});
|
|
|
|
test.skip('malformed repository', function() {
|
|
mock(mockRepo.malformed);
|
|
|
|
expect(
|
|
evaluate(function() {
|
|
/**
|
|
* get one
|
|
* @returns {number} one
|
|
*/
|
|
function getOne() {
|
|
return 1;
|
|
}
|
|
})[0].context.github
|
|
).toBe(undefined);
|
|
});
|
|
|
|
test.skip('enterprise repository', function() {
|
|
mock(mockRepo.enterprise);
|
|
|
|
expect(
|
|
evaluate(function() {
|
|
/**
|
|
* get one
|
|
* @returns {number} one
|
|
*/
|
|
function getOne() {
|
|
return 1;
|
|
}
|
|
})[0].context.github
|
|
).toEqual({
|
|
path: 'index.js',
|
|
url:
|
|
'https://github.enterprise.com/foo/bar/blob/this_is_the_sha/index.js#L6-L8'
|
|
});
|
|
});
|
|
|
|
test.skip('typedef', function() {
|
|
mock(mockRepo.master);
|
|
|
|
expect(
|
|
evaluate(function() {
|
|
/**
|
|
* A number, or a string containing a number.
|
|
* @typedef {(number|string)} NumberLike
|
|
*/
|
|
|
|
/**
|
|
* get one
|
|
* @returns {number} one
|
|
*/
|
|
function getOne() {
|
|
return 1;
|
|
}
|
|
})[0].context.github
|
|
).toEqual({
|
|
path: 'index.js',
|
|
url: 'https://github.com/foo/bar/blob/this_is_the_sha/index.js#L2-L5'
|
|
});
|
|
});
|