Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Ember Testing Template Testing Handlebars Helper" />
  <meta charset=utf-8 />
  <title>JS Bin</title>
  <script src="http://code.jquery.com/jquery.js"></script>
    <script src="http://builds.handlebarsjs.com.s3.amazonaws.com/handlebars-v1.2.1.js"></script>
  <script src="http://builds.emberjs.com/release/ember.js"></script>
  <script src="http://code.jquery.com/qunit/qunit-1.12.0.js"></script>
  <link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.12.0.css"   media="all">
</head>
  
<body>
  <div id="qunit"></div>
  <div id="qunit-fixture"></div>
  <div id="ember-testing-container">
    <div id="ember-testing"></div>
  </div>
</body>
</html>
 
Ember.Handlebars.helper('upcase', function(value) {
  return value.toUpperCase();
});
Ember.testing = true;
function createView(template, context){
  if (!context) { context = {}; }
                 
  var View = Ember.View.extend({
    controller: context,
    template: Ember.Handlebars.compile(template)
  });
  
  return View.create();
}
function append(view){
  Ember.run(function(){
    view.appendTo('#qunit-fixture');
  });
}
test('a handlebars helper', function(){
  var view = createView("{{upcase 'something'}}");
  
  append(view);
  
  equal(view.$().text(), 'SOMETHING');
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
rwjbluepro
0viewers