Skip to content

Instantly share code, notes, and snippets.

@iammerrick
Created March 12, 2013 01:37
Show Gist options
  • Save iammerrick/5139564 to your computer and use it in GitHub Desktop.
Save iammerrick/5139564 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Template Compilation Integration Test</title>
<link rel="stylesheet" href="vendor/jasmine.css" />
<script src="vendor/jasmine.js"></script>
<script src="vendor/jasmine-html.js"></script>
<script src="vendor/q.js"></script>
<script src="vendor/r.js"></script>
<script>
var loader = requirejs.config({
baseUrl: '../../../src',
paths: {
'handlebars': '../test/integration/template-compilation/vendor/handlebars.runtime'
},
shim: {
'handlebars' : {
exports: 'Handlebars'
}
},
context: 'unique'
});
var getMarkup = Q.defer();
var getOutput = Q.defer();
var getHandlebars = Q.defer();
requirejs.optimize({
baseUrl: '../../../src',
mainConfigFile: '../../../src/config.js',
name: 'ui/Button',
exclude: ['handlebars'],
optimize: 'none',
out: function(out) {
(undefined, eval)(out); // Indirect eval runs against global scope.
loader(['ui/Button', 'handlebars'], function(Button, Handlebars) {
var markup = new Button({
text: 'This is a wackidoo test!'
}).render().$el.html();
getMarkup.resolve(markup);
});
}
}, function(text) {
getOutput.resolve(text);
});
Q.spread([getOutput.promise, getMarkup.promise], function(output, markup) {
describe('Template Compilation', function() {
it('should have the correct markup', function() {
expect(markup).toEqual('This is a wackidoo test!');
});
it('should leverage the runtime version of handlebars', function() {
expect(output.match(/handlebars.js$/)).toEqual(null);
});
});
var jasmineEnv = jasmine.getEnv();
jasmineEnv.updateInterval = 250;
var htmlReporter = new jasmine.HtmlReporter();
jasmineEnv.addReporter(htmlReporter);
jasmineEnv.specFilter = function(spec) {
return htmlReporter.specFilter(spec);
};
jasmineEnv.execute();
});
</script>
</head>
<body>
<div id="jasmine"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment