forked from thlorenz/doctoc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding tests and correctly handling headers of the form '## xxx ##'
- Loading branch information
Showing
5 changed files
with
119 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
'use strict'; | ||
/*jshint asi: true */ | ||
|
||
var test = require('trap').test | ||
, transform = require('../../lib/transform') | ||
|
||
function check(md, anchors) { | ||
test('transforming ' + md , function (t) { | ||
var res = transform(md) | ||
t.ok(res.transformed, 'transforms it') | ||
console.log(require('util').inspect(res.data)) | ||
t.equal(res.data, anchors + md, 'generates correct anchors') | ||
}) | ||
} | ||
|
||
check( | ||
[ '# My Module' | ||
, 'Some text here' | ||
, '## API' | ||
, '### Method One' | ||
, 'works like this' | ||
, '### Method Two' | ||
, '#### Main Usage' | ||
, 'some main usage here' | ||
].join('\n') | ||
, [ '**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*\n\n' | ||
, '- [My Module](#my-module)\n' | ||
, '\t- [API](#api)\n' | ||
, '\t\t- [Method One](#method-one)\n' | ||
, '\t\t- [Method Two](#method-two)\n' | ||
, '\t\t\t- [Main Usage](#main-usage)\n\n' | ||
].join('') | ||
) | ||
|
||
check( | ||
[ 'My Module' | ||
, '=========' | ||
, 'Some text here' | ||
, 'API' | ||
, '---------' | ||
].join('\n') | ||
, [ '**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*\n\n' | ||
, '- [My Module](#my-module)\n' | ||
, '\t- [API](#api)\n\n' | ||
].join('') | ||
) | ||
|
||
check( | ||
[ '# My Module #' | ||
, 'Some text here' | ||
, '## API ##' | ||
].join('\n') | ||
, [ '**Table of Contents** *generated with [DocToc](http://doctoc.herokuapp.com/)*\n\n' | ||
, '- [My Module](#my-module)\n' | ||
, '\t- [API](#api)\n\n' | ||
].join('') | ||
) |