Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(index): don't throw on empty tree ()
- Loading branch information
1 parent
4381164
commit c66f9e2
Showing
2 changed files
with
40 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
var it = require('mocha').it | ||
var expect = require('chai').expect | ||
var describe = require('mocha').describe | ||
|
||
var posthtml = require('../lib') | ||
|
||
var html = null | ||
|
||
function test (html, done) { | ||
posthtml() | ||
.use(function (tree) { | ||
tree.walk(function (node) { return node }) | ||
tree.match(/(.+)/, function (node) { return node }) | ||
|
||
tree.messages.push({ | ||
type: 'warning', | ||
message: 'tree is empty' | ||
}) | ||
|
||
return tree | ||
}) | ||
.process(html, { skipParse: true }) | ||
.then(function (result) { | ||
expect('').to.eql(result.html) | ||
|
||
done() | ||
}) | ||
.catch(function (error) { | ||
done(error) | ||
}) | ||
} | ||
|
||
describe('Process', function () { | ||
it('should not throw on empty tree', function (done) { | ||
test(html, done) | ||
}) | ||
}) |