Skip to content

Commit

Permalink
Update dev-dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Feb 22, 2021
1 parent fdd5002 commit 1d58a51
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 38 deletions.
3 changes: 1 addition & 2 deletions package.json
Expand Up @@ -46,15 +46,14 @@
"browserify": "^17.0.0",
"dtslint": "^4.0.0",
"is-hidden": "^1.0.0",
"negate": "^1.0.0",
"nyc": "^15.0.0",
"prettier": "^2.0.0",
"remark": "^13.0.0",
"remark-cli": "^9.0.0",
"remark-preset-wooorm": "^8.0.0",
"tape": "^5.0.0",
"tinyify": "^3.0.0",
"xo": "^0.37.0"
"xo": "^0.38.0"
},
"scripts": {
"format": "remark . -qfo --ignore-pattern test/ && prettier . -w --loglevel warn && xo --fix",
Expand Down
60 changes: 24 additions & 36 deletions test/index.js
Expand Up @@ -4,53 +4,41 @@ var fs = require('fs')
var path = require('path')
var test = require('tape')
var remark = require('remark')
var negate = require('negate')
var hidden = require('is-hidden')
var toc = require('..')

var read = fs.readFileSync
var join = path.join

var root = join(__dirname, 'fixtures')

var fixtures = fs.readdirSync(root)

function process(value, config) {
return remark()
.use({settings: {bullet: '-'}})
.use(toc, config)
.processSync(value)
.toString()
}

test('remark-toc()', function (t) {
t.equal(typeof toc, 'function', 'should be a function')
test('Fixtures', function (t) {
var root = path.join(__dirname, 'fixtures')
var fixtures = fs.readdirSync(root)
var index = -1
var fixture
var config

t.doesNotThrow(function () {
toc.call(remark())
}, 'should not throw if not passed options')
while (++index < fixtures.length) {
fixture = fixtures[index]

t.end()
})

test('Fixtures', function (t) {
fixtures.filter(negate(hidden)).forEach(function (fixture) {
var filepath = join(root, fixture)
var output = read(join(filepath, 'output.md'), 'utf-8')
var input = read(join(filepath, 'input.md'), 'utf-8')
var config
var result
if (hidden(fixture)) {
continue
}

try {
config = JSON.parse(read(join(filepath, 'config.json')))
config = JSON.parse(
fs.readFileSync(path.join(root, fixture, 'config.json'))
)
} catch (_) {
config = {}
}

result = process(input, config)

t.equal(result, output, 'should work on `' + fixture + '`')
})
t.equal(
remark()
.use({settings: {bullet: '-'}})
.use(toc, config)
.processSync(fs.readFileSync(path.join(root, fixture, 'input.md')))
.toString(),
String(fs.readFileSync(path.join(root, fixture, 'output.md'))),
'should work on `' + fixture + '`'
)
}

t.end()
})

0 comments on commit 1d58a51

Please sign in to comment.