Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Got tap-parser and remote test wired up. All set to actually test assertions on the TAP output of the .sjs test.
- Loading branch information
Showing
3 changed files
with
42 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log(__filename); |
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,23 @@ | ||
'use strict'; | ||
const stream = require('stream'); | ||
const parser = require('tap-parser'); | ||
|
||
/** | ||
* Parses TAP aysncronously resolving a Promise with an `Object` | ||
* representing the structured TAP. | ||
* | ||
* @param {string} tap | ||
* @returns Promise resolves with an Object | ||
*/ | ||
function parseTAP(tap) { | ||
return new Promise((resolve, reject) => { | ||
const strReader = new stream.Readable(); | ||
strReader.push(tap); | ||
strReader.push(null); | ||
|
||
const writable = parser(resolve); | ||
strReader.pipe(writable); | ||
}); | ||
} | ||
|
||
module.exports.parseTAP = parseTAP; |
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,18 @@ | ||
'use strict'; | ||
|
||
const test = require('tape-catch'); | ||
const remote = require('../marklogic-remote')(/* connection */); | ||
const parseTAP = require('../lib/tap-helpers').parseTAP; | ||
|
||
test('assert.throws()', (assert) => { | ||
assert.plan(1); | ||
remote('test/throws.test.sjs') // CHANGE ME | ||
.then((tap) => { | ||
//assert.comment(tap.length); | ||
parseTAP(tap) | ||
.then(tree => assert.true('object' === typeof tree, 'Non-null parse tree (baby steps)')) | ||
.catch(error => assert.fail(error)); | ||
}) | ||
.catch((error, stderr) => assert.fail(error.body.errorResponse.message)); | ||
}); | ||
|