mirror of
https://github.com/documentationjs/documentation.git
synced 2026-01-18 14:17:30 +00:00
49 lines
970 B
JavaScript
49 lines
970 B
JavaScript
/*eslint-disable no-unused-vars*/
|
|
const inferAugments = require('../../../src/infer/augments');
|
|
const parse = require('../../../src/parsers/javascript');
|
|
|
|
function toComment(fn, filename) {
|
|
return parse(
|
|
{
|
|
file: filename,
|
|
source: fn instanceof Function ? '(' + fn.toString() + ')' : fn
|
|
},
|
|
{}
|
|
)[0];
|
|
}
|
|
|
|
function evaluate(code, filename) {
|
|
return inferAugments(toComment(code, filename));
|
|
}
|
|
|
|
test('inferAugments', function() {
|
|
expect(evaluate('/** */class A extends B {}').augments).toEqual([
|
|
{
|
|
name: 'B',
|
|
title: 'augments'
|
|
}
|
|
]);
|
|
|
|
expect(evaluate('/** */interface A extends B, C {}').augments).toEqual([
|
|
{
|
|
name: 'B',
|
|
title: 'extends'
|
|
},
|
|
{
|
|
name: 'C',
|
|
title: 'extends'
|
|
}
|
|
]);
|
|
|
|
expect(evaluate('/** */interface A extends B, C {}', 'test.ts').augments).toEqual([
|
|
{
|
|
name: 'B',
|
|
title: 'extends'
|
|
},
|
|
{
|
|
name: 'C',
|
|
title: 'extends'
|
|
}
|
|
]);
|
|
});
|