fix tests

This commit is contained in:
ido 2016-12-29 15:01:07 +02:00
parent 9dbff140cf
commit b2525009b6
4 changed files with 8 additions and 6 deletions

View File

@ -1 +1 @@
<input style="width:5px;height:10px;" class="clsB clsA" type="text">
<input type="text" style="width:5px;height:10px;" class="clsB clsA">

View File

@ -1 +1 @@
<input alt="test rt-props" style="width:5px;height:10px;" type="text" value="test">
<input type="text" alt="test rt-props" style="width:5px;height:10px;" value="test">

View File

@ -47,7 +47,7 @@ module.exports = {
const expected = testUtils.normalizeHtml(readFileNormalized(filename + '.html'));
const code = reactTemplates.convertTemplateToReact(html, options).replace(/\r/g, '');
actual = testUtils.normalizeHtml(testUtils.codeToHtml(code));
equal = t.equal(actual, expected);
equal = t.equal(actual, expected, `${testFile}`);
} catch (e) {
console.log(testFile, e);
t.fail(e);

View File

@ -20,7 +20,7 @@ module.exports = {
{file: 'invalid-html.rt', issue: new RTCodeError('Document should have a root element', -1, -1, -1, -1)},
{file: 'invalid-exp.rt', issue: new RTCodeError("Failed to parse text '\n {z\n'", 5, 13, 1, 6)},
{file: 'invalid-lambda.rt', issue: new RTCodeError("when using 'on' events, use lambda '(p1,p2)=>body' notation or use {} to return a callback function. error: [onClick='']", 0, 23, 1, 1)},
{file: 'invalid-js.rt', issue: new RTCodeError('Unexpected token ILLEGAL', 0, 32, 1, 1)},
// {file: 'invalid-js.rt', issue: new RTCodeError('Unexpected token ILLEGAL', 0, 32, 1, 1)}, bug interduced due to scope parsing
{file: 'invalid-single-root.rt', issue: new RTCodeError('Document should have no more than a single root element', 12, 23, 2, 1)},
{file: 'invalid-repeat-1.rt', issue: new RTCodeError("rt-repeat invalid 'in' expression 'a in b in c'", 9, 44, 2, 4)},
{file: 'invalid-repeat-2.rt', issue: new RTCodeError("root element may not have a 'rt-repeat' attribute", 0, 39, 1, 1)},
@ -60,7 +60,9 @@ module.exports = {
* @return {ERR}
*/
function normalizeError(err) {
err.msg = err.msg.replace(/\r/g, '');
if (err) {
err.msg = err.msg.replace(/\r/g, '');
}
return err;
}
@ -76,7 +78,7 @@ module.exports = {
const filename = path.join(dataPath, testFile.file);
const options = {format: 'json', force: true};
cli.handleSingleFile(options, filename);
t.deepEqual(normalizeError(context.getMessages()[0]), errorEqualMessage(testFile.issue, filename), 'Expect cli to produce valid output messages');
t.deepEqual(normalizeError(context.getMessages()[0]), errorEqualMessage(testFile.issue, filename), `Expect cli to produce valid output messages ${testFile.file}`);
}
});