-
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for transformers as async functions
Closes GH-35.
- Loading branch information
Showing
4 changed files
with
54 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict' | ||
|
||
var test = require('tape') | ||
var vfile = require('vfile') | ||
var unified = require('..') | ||
|
||
test('async function transformer () {}', function(t) { | ||
var f | ||
var n | ||
var e | ||
|
||
t.plan(5) | ||
|
||
f = vfile('alpha') | ||
n = {type: 'bravo'} | ||
e = {type: 'charlie'} | ||
|
||
unified() | ||
.use(plugin) | ||
.run(n, f, function(err, a, file) { | ||
t.error(err, 'should’t fail') | ||
t.equal(a, e, 'passes given tree to `done`') | ||
t.equal(file, f, 'passes given file to `done`') | ||
}) | ||
|
||
function plugin() { | ||
return transformer | ||
} | ||
|
||
async function transformer(tree, file) { | ||
t.equal(tree, n, 'passes correct tree to an async function') | ||
t.equal(file, f, 'passes correct file to an async function') | ||
return e | ||
} | ||
}) |
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