JSFiddle - React, Tailwind, and code Playground
by hyperthalamus
HTML
<script src="http://mobileka.mercularity.com/tests/automated/libraries/qunit.js"></script>
<link rel="stylesheet" href="http://mobileka.mercularity.com/tests/automated/libraries/qunit.css">
<h1 id="qunit-header">QUnit example</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"><li style="visibility: hidden;"></li></ol>
<div id="qunit-fixture">test markup, will be hidden</div>
<div id="display"></div>
JavaScript
//emulate legacy getter/setter API using ES5 APIs
try {
if (!Object.prototype.__defineGetter__ &&
Object.defineProperty({},"x",{get: function(){return true}}).x) {
Object.defineProperty(Object.prototype, "__defineGetter__",
{enumerable: false, configurable: true,
value: function(name,func)
{Object.defineProperty(this,name,
{get:func,enumerable: true,configurable: true});
}});
Object.defineProperty(Object.prototype, "__defineSetter__",
{enumerable: false, configurable: true,
value: function(name,func)
{Object.defineProperty(this,name,
{set:func,enumerable: true,configurable: true});
}});
}
} catch(defPropException) {/*Do nothing if an exception occurs*/};
function testComponent(){
var testProperty;
Object.defineProperty(this, "testProperty",
{
get : function()
{
return testProperty;
},
set : function(val)
{
testProperty = val;
}
});
}
function initTest()
{
var testObject;
module("DefinePropertyTest",
{
setup: function(){
testObject = new testComponent();
},
teardown: function(){
testObject = null;
}
});
test("defineProperty test", function()
{
testObject.testProperty = "correct";
ok(testObject.testProperty == "correct", "defineProperty passed");
});
}
initTest();