Skip to content

Commit

Permalink
Merge pull request #686 from wycats/amd-tests
Browse files Browse the repository at this point in the history
Falsy AMD module names in version 1.2.0
  • Loading branch information
kpdecker committed Dec 26, 2013
2 parents 9f1b3bc + 7311ab0 commit 77fd7dc
Show file tree
Hide file tree
Showing 4 changed files with 2,130 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ module.exports = function(grunt) {
all: {
options: {
build: process.env.TRAVIS_JOB_ID,
urls: ['http://localhost:9999/spec/?headless=true'],
urls: ['http://localhost:9999/spec/?headless=true', 'http://localhost:9999/spec/amd.html?headless=true'],
detailedError: true,
concurrency: 2,
browsers: [
Expand Down Expand Up @@ -162,7 +162,7 @@ module.exports = function(grunt) {
},

files: ['src/*', 'lib/**/*.js', 'spec/**/*.js'],
tasks: ['build', 'tests', 'test']
tasks: ['build', 'amd', 'tests', 'test']
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-connect": "~0.5.0",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-jshint": "~0.7.2",
"grunt-contrib-jshint": "0.x",
"grunt-contrib-requirejs": "~0.4.1",
"grunt-contrib-uglify": "~0.2.2",
"grunt-contrib-watch": "~0.5.3",
Expand Down
73 changes: 73 additions & 0 deletions spec/amd.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<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/require.js"></script>

<script src="/spec/env/common.js"></script>
<script>
requirejs.config({
paths: {
handlebars: '/dist/handlebars.amd',
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) {
var ret;
eval('ret = ' + templateSpec);
return ret;
}
</script>
<script>
onload = function(){

require(['handlebars'], function(Handlebars) {
window.Handlebars = Handlebars['default'];

require(['tests'], function(Handlebars) {
// The test harness leaks under FF. We should have decent global leak coverage from other tests
if (!navigator.userAgent.match(/Firefox\/([\d.]+)/)) {
mocha.checkLeaks();
}
mocha.run();
});
});
};
</script>
</head>
<body>
<div id="mocha"></div>
</body>
</html>
Loading

0 comments on commit 77fd7dc

Please sign in to comment.