| 1 |
'use strict'; |
| 2 |
|
| 3 |
const fs = require('fs'); |
| 4 |
const path = require('path'); |
| 5 |
|
| 6 |
/* This is a wrapper around the roundtrip testing script */ |
| 7 |
const rtTest = require('../../bin/roundtrip-test.js'); |
| 8 |
const yaml = require('js-yaml'); |
| 9 |
|
| 10 |
// Read ids from a file and return the first line of the file |
| 11 |
function getTestRunId(opts) { |
| 12 |
const testRunIdFile = opts.testRunIdFile || path.resolve(__dirname, 'parsoid.rt-test.ids'); |
| 13 |
return fs.readFileSync(testRunIdFile, 'utf-8').split('\n')[0]; |
| 14 |
} |
| 15 |
|
| 16 |
function runRoundTripTest(config, test) { |
| 17 |
return rtTest.runTests(test.title, { |
| 18 |
prefix: test.prefix, |
| 19 |
parsoidURLOpts: config.parsoidPHP, |
| 20 |
}, rtTest.xmlFormat).then(function(result) { |
| 21 |
return result.output; |
| 22 |
}); |
| 23 |
} |
| 24 |
|
| 25 |
if (typeof module === 'object') { |
| 26 |
module.exports.runRoundTripTest = runRoundTripTest; |
| 27 |
module.exports.getTestRunId = getTestRunId; |
| 28 |
} |