From bb3b2d12d4adbbe0a2c8c5488ef6e9946c2d5b8e Mon Sep 17 00:00:00 2001 From: ulises Gascon Date: Wed, 5 Jun 2019 18:50:18 +0200 Subject: [PATCH] Basic support for unit testing added #759 - Babel config now supports modules (imp/exp) - Added module support in the index.html - Added sample function in main.js for future unit testing - Tests updated --- app/templates/babelrc | 7 ++++++- app/templates/index.html | 4 ++++ app/templates/main.js | 10 +++++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/templates/babelrc b/app/templates/babelrc index a29ac998..4a7ff2ba 100644 --- a/app/templates/babelrc +++ b/app/templates/babelrc @@ -1,5 +1,10 @@ { "presets": [ - "@babel/preset-env" + ["@babel/preset-env", { + "sourceType": "unambiguous", + "targets": { + "esmodules": true + } + }] ] } diff --git a/app/templates/index.html b/app/templates/index.html index ed9664f8..3e418190 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -116,7 +116,11 @@

'Allo, 'Allo!

<%_ } -%> + <%_ if (includeUnit) { -%> + + <%_ } else { -%> + <%_ } -%> diff --git a/app/templates/main.js b/app/templates/main.js index 3b21d0d9..cb478f12 100644 --- a/app/templates/main.js +++ b/app/templates/main.js @@ -1,4 +1,12 @@ -console.log('\'Allo \'Allo!'); +<%_ if (includeUnit) { -%> +export function greeting() { + return '\'Allo \'Allo!'; +} + +console.log(greeting()); +<%_ } else { -%> + console.log('\'Allo \'Allo!'); +<%_ } -%> <%_ if (includeBootstrap) { -%> // Uncomment to enable Bootstrap tooltips