diff --git a/package.json b/package.json index 6928a3d..29c3f55 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Light weight templates for react -> write html get valid react code", "main": "./src/reactTemplates.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "node test/src/test.js" }, "repository": { "type": "git", diff --git a/src/reactTemplates.js b/src/reactTemplates.js index f02175a..2dcd03a 100644 --- a/src/reactTemplates.js +++ b/src/reactTemplates.js @@ -108,7 +108,6 @@ function generateProps(node, context) { str = str.trim(); if (!str || str.indexOf(':') === -1) { return null; - } var res = str.split(':'); res[0] = res[0].trim(); @@ -253,5 +252,8 @@ function convertFile(source, target) { fs.writeFileSync(target, js); } -module.exports.convertTemplateToReact = convertTemplateToReact; -module.exports.convertFile = convertFile; \ No newline at end of file +module.exports = { + convertTemplateToReact: convertTemplateToReact, + convertFile: convertFile, + _test: {} +}; \ No newline at end of file diff --git a/test/data/div.rt.js b/test/data/div.rt.js index ddb946d..7a36e77 100644 --- a/test/data/div.rt.js +++ b/test/data/div.rt.js @@ -2,6 +2,7 @@ define([ 'react', 'lodash' ], function (React, _) { + 'use strict'; return function () { return React.DOM.div.apply(this, _.flatten([{}].concat([]))); }; diff --git a/test/data/repeat.rt.js b/test/data/repeat.rt.js index ec9fbb1..685bc59 100644 --- a/test/data/repeat.rt.js +++ b/test/data/repeat.rt.js @@ -2,6 +2,7 @@ define([ 'react', 'lodash' ], function (React, _) { + 'use strict'; function generated1(items, itemsIndex, evt) { this.happend(evt); return false; diff --git a/test/data/test.rt.js b/test/data/test.rt.js index 609cf33..0adc4cb 100644 --- a/test/data/test.rt.js +++ b/test/data/test.rt.js @@ -2,6 +2,7 @@ define([ 'react', 'lodash' ], function (React, _) { + 'use strict'; return function () { return React.DOM.div.apply(this, _.flatten([{}].concat([ React.DOM.div.apply(this, _.flatten([{ diff --git a/test/src/test.js b/test/src/test.js index 8baf232..5787dee 100644 --- a/test/src/test.js +++ b/test/src/test.js @@ -7,7 +7,7 @@ var path = require('path'); var dataPath = path.resolve(__dirname, '..', 'data'); -test('timing test', function (t) { +test('conversion test', function (t) { var files = ['div.rt', 'test.rt', 'repeat.rt']; t.plan(files.length); @@ -21,7 +21,7 @@ test('timing test', function (t) { var actual = reactTemplates.convertTemplateToReact(html); t.equal(actual, expected); if (actual !== expected) { - fs.writeFileSync(filename + ".actual.js", actual); + fs.writeFileSync(filename + '.actual.js', actual); } } });