var test = require('tap').test; var remark = require('remark'); var formatMarkdown = require('../lib/format_markdown'); test('main', function (t) { t.deepEqual(formatMarkdown(remark().parse('Converts from `Result` to `?Error`')), '

Converts from Result<T> to ?Error

\n'); t.done(); }); test('type', function (t) { var formatType = formatMarkdown.type; t.deepEqual(formatType(undefined), ''); t.deepEqual(formatType({ type: 'NameExpression', name: 'Foo' }), 'Foo'); t.deepEqual(formatType({ type: 'NameExpression', name: 'Foo' }, ['Foo']), 'Foo'); t.deepEqual(formatType({ type: 'UnionType', elements: [ { type: 'NameExpression', name: 'Foo' }, { type: 'NameExpression', name: 'Bar' } ] }), '(Foo | Bar)'); t.deepEqual(formatType({ type: 'AllLiteral' }), 'Any'); t.deepEqual(formatType({ type: 'RestType' }), '...'); t.deepEqual(formatType({ type: 'OptionalType', expression: { type: 'NameExpression', name: 'Foo' } }), '[Foo]'); t.deepEqual(formatType({ type: 'TypeApplication', expression: { type: 'NameExpression', name: 'Foo' }, applications: [{ type: 'NameExpression', name: 'Bar' }] }), 'Foo<Bar>'); t.deepEqual(formatType({ type: 'UndefinedLiteral' }), 'undefined'); t.done(); }); test('autolink', function (t) { var autolink = formatMarkdown.link; t.equal(autolink([], 'Foo'), 'Foo'); t.equal(autolink(['Foo'], 'Foo'), 'Foo'); t.equal(autolink([], 'Array'), 'Array'); t.equal(autolink([], 'C&O'), 'C&O'); t.done(); });