emaphp / underscore-template-loader

A Underscore and Lodash template loader for Webpack
MIT License
104 stars 24 forks source link

Add tests :). #7

Closed SpaceK33z closed 8 years ago

SpaceK33z commented 8 years ago

I added unit tests with mocha. You can run them with npm test.

I also added an .editorconfig file. The main reason for this was that the tests compare the output of the loader, and if even one character of white space is stripped, they will fail.

The tests work by mocking Webpack, running a template in test/template/ through the loader and comparing the output with a given .txt file in test/template/output/.

I have not yet tested lib/macroParser.js. I would recommend adding tests for this as well (in a seperate test file); I don't know yet if I have the time for it.

SpaceK33z commented 8 years ago

I also refactored index.js a little; it had an unnecessary function wrapper in it and the modules were required inside module.exports. Hope you don't mind ;).

emaphp commented 8 years ago

Outstanding! I added additional tests for improving macro support. The issue regarding macros located at the beginning has been corrected. The missing character problem was also corrected and the documentation has now 2 additional sub-sections regarding macro arguments and escaping. Changes are now available in v0.5.1. Thanks again @SpaceK33z , truly a wonderful contribution.