JSFiddle - React, Tailwind, and code Playground

by Derek Anderson

HTML

<div>hi</div><br/>

JavaScript

//The goal of gUnit is to allow inline unit test writing.
//by keeping test code relevant and not seperated we can 
//ensure that we are always writing unit tests, for even
//small tasks. 
//
//This is good, because it will allow us to be more responsive
//to any problems with interactions.
var cmg = {};
(function(cmg){
    cmg.gUnit = function(testfunc){
        var tests = {};               
        var didipass = true;        
        var displaydiv = $('<div/>');
        
        for (var mainfunc in testfunc)
          {
          if(typeof(testfunc[mainfunc]) == "function"){
                $('<h2/>',{
                    text: mainfunc
                }).appendTo(displaydiv);
              for (var func in new testfunc[mainfunc])
              {alert(func);
              var testfunction = new testfunc[mainfunc];
              if(typeof(testfunction[func]) == "function"){
                  if(func.slice(0,4) == "test"){
                      tests[func] = testfunction[func]();
                      if(tests[func] == false){didipass = tests[func]};
                   $('<li/>',{
                     text: func.slice(4, func.length).replace(/_/g," ") + ' : ' + tests[func]
                   }).appendTo(displaydiv);
                  }
              }        
            }
          }                   
        }
                     
        $('<h1/>',{
             text: 'did i pass: ' + didipass
        }).prependTo(displaydiv);
              
        var testlist = $('<ul/>');
       
        testlist.appendTo(displaydiv);
        displaydiv.appendTo("body");
    };
})(cmg);


//simple jQuery document.ready wrapper that allows
//for even the smallest snippets to be unit tested
(function($){
    function _$(){}
    _$.prototype = {
        init: function() {
            //do your stuff here, even for a document
            //ready
            $("div").text("winnder winner");
            
            //write test inline through a prototype using
           ...