From 2b38b0ca31d55c17652c147415432def9d470736 Mon Sep 17 00:00:00 2001 From: avim Date: Tue, 11 Nov 2014 16:55:32 +0200 Subject: [PATCH] normalize html before compare in tests whitespace forgiving. --- test/data/scope.rt.html | 10 +++++++++- test/src/test.js | 9 +++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/test/data/scope.rt.html b/test/data/scope.rt.html index c0342cf..644c461 100644 --- a/test/data/scope.rt.html +++ b/test/data/scope.rt.html @@ -1 +1,9 @@ -
Item:#0 = aItem:#1 = bItem:#2 = c
items not in scopeitem not in scope
\ No newline at end of file +
+
+ Item:#0 = a + Item:#1 = b + Item:#2 = c +
+ items not in scope + item not in scope +
\ No newline at end of file diff --git a/test/src/test.js b/test/src/test.js index fed1f01..d0f800e 100644 --- a/test/src/test.js +++ b/test/src/test.js @@ -5,6 +5,7 @@ var fs = require('fs'); var _ = require('lodash'); var path = require('path'); var React = require('react'); +var cheerio = require('cheerio'); var dataPath = path.resolve(__dirname, '..', 'data'); @@ -27,6 +28,10 @@ test('conversion test', function (t) { } }); +function normalizeHtml(html) { + return cheerio.load(html,{normalizeWhitespace:true}).html(); +} + test('html tests', function (t) { var files = ['scope.rt']; t.plan(files.length); @@ -50,13 +55,13 @@ test('html tests', function (t) { render: eval(code) })); var actual = React.renderToStaticMarkup(comp()); - console.log(actual); + actual = normalizeHtml(actual); + expected = normalizeHtml(actual); t.equal(actual, expected); if (actual !== expected) { fs.writeFileSync(filename + '.actual.html', actual); } } - }); test('util.isStale', function (t) {