summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkpdecker <kpdecker@gmail.com>2014-08-25 22:06:15 -0500
committerkpdecker <kpdecker@gmail.com>2014-08-25 22:06:15 -0500
commit09d3c74c7ffadef2db1260b50f08bc1d59ec3ed6 (patch)
tree5574ea6aa9f217b953fa4e4c193b9956fca79c36
parentc98147b31f12d97d219abaa699ef3bae32bbeb5e (diff)
downloadhandlebars.js-09d3c74c7ffadef2db1260b50f08bc1d59ec3ed6.zip
handlebars.js-09d3c74c7ffadef2db1260b50f08bc1d59ec3ed6.tar.gz
handlebars.js-09d3c74c7ffadef2db1260b50f08bc1d59ec3ed6.tar.bz2
Convert build to expose UMD from the default files
-rw-r--r--Gruntfile.js13
-rw-r--r--spec/amd-runtime.html89
-rw-r--r--spec/umd-runtime.html89
-rw-r--r--spec/umd.html109
4 files changed, 299 insertions, 1 deletions
diff --git a/Gruntfile.js b/Gruntfile.js
index 6cbef6e..09e4787 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -43,7 +43,7 @@ module.exports = function(grunt) {
packager: {
global: {
- type: 'global',
+ type: 'umd',
export: 'Handlebars',
files: [{
cwd: 'lib/',
@@ -145,6 +145,17 @@ module.exports = function(grunt) {
{browserName: 'internet explorer', version: 9, platform: 'Windows 7'}
]
}
+ },
+ sanity: {
+ options: {
+ build: process.env.TRAVIS_JOB_ID,
+ urls: ['http://localhost:9999/spec/umd.html?headless=true', 'http://localhost:9999/spec/amd-runtime?headless=true', 'http://localhost:9999/spec/umd-runtime.html?headless=true'],
+ detailedError: true,
+ concurrency: 2,
+ browsers: [
+ {browserName: 'chrome'}
+ ]
+ }
}
},
diff --git a/spec/amd-runtime.html b/spec/amd-runtime.html
new file mode 100644
index 0000000..19bccdb
--- /dev/null
+++ b/spec/amd-runtime.html
@@ -0,0 +1,89 @@
+<html>
+ <head>
+ <title>Mocha</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+
+ <link rel="stylesheet" href="/node_modules/mocha/mocha.css" />
+ <style>
+ .headless .suite > h1,
+ .headless .test.pass {
+ display: none;
+ }
+ </style>
+
+ <script>
+ // Show only errors in "headless", non-interactive mode.
+ if (/headless=true/.test(location.href)) {
+ document.documentElement.className = 'headless';
+ }
+ </script>
+ <script src="/node_modules/mocha/mocha.js"></script>
+ <script>
+ mocha.setup('bdd');
+ </script>
+
+ <script src="/spec/env/json2.js"></script>
+ <script src="/spec/env/require.js"></script>
+
+ <script src="/spec/env/common.js"></script>
+ <script>
+ requirejs.config({
+ paths: {
+ 'handlebars.runtime': '/dist/handlebars.runtime.amd'
+ }
+ });
+ </script>
+ <script>
+ onload = function(){
+ require(['handlebars.runtime'], function(Handlebars) {
+ describe('runtime', function() {
+ it('should load', function() {
+ equal(!!Handlebars['default'].template, true);
+ equal(!!Handlebars['default'].VERSION, true);
+ });
+ });
+
+ mocha.globals(['mochaResults'])
+ // The test harness leaks under FF. We should have decent global leak coverage from other tests
+ if (!navigator.userAgent.match(/Firefox\/([\d.]+)/)) {
+ mocha.checkLeaks();
+ }
+ var runner = mocha.run();
+
+ //Reporting for saucelabs
+ var failedTests = [];
+ runner.on('end', function(){
+ window.mochaResults = runner.stats;
+ window.mochaResults.reports = failedTests;
+ });
+
+ runner.on('fail', logFailure);
+
+ function logFailure(test, err){
+
+ var flattenTitles = function(test){
+ var titles = [];
+ while (test.parent.title){
+ titles.push(test.parent.title);
+ test = test.parent;
+ }
+ return titles.reverse();
+ };
+
+ failedTests.push({
+ name: test.title,
+ result: false,
+ message: err.message,
+ stack: err.stack,
+ titles: flattenTitles(test)
+ });
+ }
+ });
+ };
+ </script>
+ </head>
+ <body>
+ <div id="mocha"></div>
+ </body>
+</html>
diff --git a/spec/umd-runtime.html b/spec/umd-runtime.html
new file mode 100644
index 0000000..90b9144
--- /dev/null
+++ b/spec/umd-runtime.html
@@ -0,0 +1,89 @@
+<html>
+ <head>
+ <title>Mocha</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+
+ <link rel="stylesheet" href="/node_modules/mocha/mocha.css" />
+ <style>
+ .headless .suite > h1,
+ .headless .test.pass {
+ display: none;
+ }
+ </style>
+
+ <script>
+ // Show only errors in "headless", non-interactive mode.
+ if (/headless=true/.test(location.href)) {
+ document.documentElement.className = 'headless';
+ }
+ </script>
+ <script src="/node_modules/mocha/mocha.js"></script>
+ <script>
+ mocha.setup('bdd');
+ </script>
+
+ <script src="/spec/env/json2.js"></script>
+ <script src="/spec/env/require.js"></script>
+
+ <script src="/spec/env/common.js"></script>
+ <script>
+ requirejs.config({
+ paths: {
+ 'handlebars.runtime': '/dist/handlebars.runtime'
+ }
+ });
+ </script>
+ <script>
+ onload = function(){
+ require(['handlebars.runtime'], function(Handlebars) {
+ describe('runtime', function() {
+ it('should load', function() {
+ equal(!!Handlebars.template, true);
+ equal(!!Handlebars.VERSION, true);
+ });
+ });
+
+ mocha.globals(['mochaResults'])
+ // The test harness leaks under FF. We should have decent global leak coverage from other tests
+ if (!navigator.userAgent.match(/Firefox\/([\d.]+)/)) {
+ mocha.checkLeaks();
+ }
+ var runner = mocha.run();
+
+ //Reporting for saucelabs
+ var failedTests = [];
+ runner.on('end', function(){
+ window.mochaResults = runner.stats;
+ window.mochaResults.reports = failedTests;
+ });
+
+ runner.on('fail', logFailure);
+
+ function logFailure(test, err){
+
+ var flattenTitles = function(test){
+ var titles = [];
+ while (test.parent.title){
+ titles.push(test.parent.title);
+ test = test.parent;
+ }
+ return titles.reverse();
+ };
+
+ failedTests.push({
+ name: test.title,
+ result: false,
+ message: err.message,
+ stack: err.stack,
+ titles: flattenTitles(test)
+ });
+ }
+ });
+ };
+ </script>
+ </head>
+ <body>
+ <div id="mocha"></div>
+ </body>
+</html>
diff --git a/spec/umd.html b/spec/umd.html
new file mode 100644
index 0000000..5f3863f
--- /dev/null
+++ b/spec/umd.html
@@ -0,0 +1,109 @@
+<html>
+ <head>
+ <title>Mocha</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+
+ <link rel="stylesheet" href="/node_modules/mocha/mocha.css" />
+ <style>
+ .headless .suite > h1,
+ .headless .test.pass {
+ display: none;
+ }
+ </style>
+
+ <script>
+ // Show only errors in "headless", non-interactive mode.
+ if (/headless=true/.test(location.href)) {
+ document.documentElement.className = 'headless';
+ }
+ </script>
+ <script src="/node_modules/mocha/mocha.js"></script>
+ <script>
+ mocha.setup('bdd');
+ </script>
+
+ <script src="/spec/env/json2.js"></script>
+ <script src="/spec/env/require.js"></script>
+
+ <script src="/spec/env/common.js"></script>
+ <script>
+ requirejs.config({
+ paths: {
+ handlebars: '/dist/handlebars',
+ tests: '/tmp/tests'
+ }
+ });
+
+ var CompilerContext = {
+ compile: function(template, options) {
+ var templateSpec = handlebarsEnv.precompile(template, options);
+ return handlebarsEnv.template(safeEval(templateSpec));
+ },
+ compileWithPartial: function(template, options) {
+ return handlebarsEnv.compile(template, options);
+ }
+ };
+
+ function safeEval(templateSpec) {
+ try {
+ var ret;
+ eval('ret = ' + templateSpec);
+ return ret;
+ } catch (err) {
+ console.error(templateSpec);
+ throw err;
+ }
+ }
+ </script>
+ <script>
+ onload = function(){
+
+ require(['handlebars'], function(Handlebars) {
+ window.Handlebars = Handlebars;
+
+ require(['tests'], function() {
+ mocha.globals(['mochaResults'])
+ // The test harness leaks under FF. We should have decent global leak coverage from other tests
+ if (!navigator.userAgent.match(/Firefox\/([\d.]+)/)) {
+ mocha.checkLeaks();
+ }
+ var runner = mocha.run();
+
+ //Reporting for saucelabs
+ var failedTests = [];
+ runner.on('end', function(){
+ window.mochaResults = runner.stats;
+ window.mochaResults.reports = failedTests;
+ });
+
+ runner.on('fail', logFailure);
+
+ function logFailure(test, err){
+
+ var flattenTitles = function(test){
+ var titles = [];
+ while (test.parent.title){
+ titles.push(test.parent.title);
+ test = test.parent;
+ }
+ return titles.reverse();
+ };
+
+ failedTests.push({
+ name: test.title,
+ result: false,
+ message: err.message,
+ stack: err.stack,
+ titles: flattenTitles(test)
+ });
+ };
+ });
+ });
+ };
+ </script>
+ </head>
+ <body>
+ <div id="mocha"></div>
+ </body>
+</html>