Skip to content

Commit

Permalink
Addresses #3: Mostly plumbing
Browse files Browse the repository at this point in the history
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
jmakeig committed Sep 1, 2016
1 parent cf71c61 commit dda9bd9
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions file.js
@@ -0,0 +1 @@
console.log(__filename);
23 changes: 23 additions & 0 deletions lib/tap-helpers.js
@@ -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;
18 changes: 18 additions & 0 deletions test/throws.test.js
@@ -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));
});

0 comments on commit dda9bd9

Please sign in to comment.