documentation/test/linker.js
Tom MacWright 25152edeb9 style(prettier): Use prettier for code formatting (#710)
* style(prettier): Use prettier for code formatting

This saves us style issues. Also adds husky and lint-staged for pre-commit testing

Refs https://github.com/documentationjs/documentation/issues/709
2017-04-10 14:25:45 -04:00

55 lines
1.1 KiB
JavaScript

'use strict';
var LinkerStack = require('../lib/output/util/linker_stack'),
test = require('tap').test;
test('linkerStack', function(t) {
var linkerStack = new LinkerStack({});
t.equal(
linkerStack.link('string'),
'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String',
'Default global resolution of string'
);
t.equal(
new LinkerStack({
paths: {
Point: 'http://geojson.org/geojson-spec.html#point'
}
}).link('Point'),
'http://geojson.org/geojson-spec.html#point',
'Custom hardcoded path for a GeoJSON type'
);
t.equal(
new LinkerStack({
paths: {
Image: 'http://custom.com/'
}
}).link('Image'),
'http://custom.com/',
'Prefers config link to native.'
);
var linker = new LinkerStack({
paths: {
Image: 'http://custom.com/'
}
});
linker.namespaceResolver(
[
{
namespace: 'Image'
}
],
function(namespace) {
return '#' + namespace;
}
);
t.equal(linker.link('Image'), '#Image', 'Prefers local link over all.');
t.end();
});