nakome
12/5/2014 - 4:29 AM

QUnit Example // source http://jsbin.com/foloje

QUnit Example

// source http://jsbin.com/foloje

var html = (function(){
  'use strict';
  return{
    tag:function(el){
      return document.querySelector(el);
    },
    render:function(tag,text,atributes){
      if(typeof tag === 'undefined'){ tag = '';}
      if(typeof text === 'undefined'){ text = '';}
      if(typeof atributes === 'undefined'){ atributes = '';}
      return '<'+tag+'\t '+atributes+'>'+text+'</'+tag+'>';
    }
  };
}).call(this);


QUnit.test( 
  html.render('p','Hello World','class="foo"'),
  function( assert ) {
    window.pollute = true;
    assert.strictEqual( pollute, true );
  }
);
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>QUnit Example</title>
  <link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.16.0.css">
</head>
<body>
  <div id="qunit"></div>
  <div id="qunit-fixture"></div>
  <script src="http://code.jquery.com/qunit/qunit-1.16.0.js"></script>
  <script src="tests.js"></script>
<script id="jsbin-javascript">
var html = (function(){
  'use strict';
  return{
    tag:function(el){
      return document.querySelector(el);
    },
    render:function(tag,text,atributes){
      if(typeof tag === 'undefined'){ tag = '';}
      if(typeof text === 'undefined'){ text = '';}
      if(typeof atributes === 'undefined'){ atributes = '';}
      return '<'+tag+'\t '+atributes+'>'+text+'</'+tag+'>';
    }
  };
}).call(this);


QUnit.test( 
  html.render('p','Hello World','class="foo"'),
  function( assert ) {
    window.pollute = true;
    assert.strictEqual( pollute, true );
  }
);
</script>

<script id="jsbin-source-html" type="text/html"><!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>QUnit Example</title>
  <link rel="stylesheet" href="//code.jquery.com/qunit/qunit-1.16.0.css">
</head>
<body>
  <div id="qunit"></div>
  <div id="qunit-fixture"></div>
  <script src="//code.jquery.com/qunit/qunit-1.16.0.js"><\/script>
  <script src="tests.js"><\/script>
</body>
</html></script>


<script id="jsbin-source-javascript" type="text/javascript">
var html = (function(){
  'use strict';
  return{
    tag:function(el){
      return document.querySelector(el);
    },
    render:function(tag,text,atributes){
      if(typeof tag === 'undefined'){ tag = '';}
      if(typeof text === 'undefined'){ text = '';}
      if(typeof atributes === 'undefined'){ atributes = '';}
      return '<'+tag+'\t '+atributes+'>'+text+'</'+tag+'>';
    }
  };
}).call(this);


QUnit.test( 
  html.render('p','Hello World','class="foo"'),
  function( assert ) {
    window.pollute = true;
    assert.strictEqual( pollute, true );
  }
);



</script></body>
</html>