This utility is fixture for QUnit.
If you have to use fixture It has some ways.
<div id="fixture">
<span>1</span>
</div>
This case has some cons. fixture
is too hard to read and maintain If I have many fixture. For example. It can't know fixture
in testcase. So. I search for #fixture
in html but It is hard to search.
jQuery("<span>1</span>").appendTo("#fixture");
This case has resolve uppon problem. but I feel like a hack.
So. I made fixture
. If you use fixture
you can easy use fixture
.
npm install qunit-fixture
or
bower install qunit-fixture
<script src="jquery.js"></script>
<script src="../bower_components/qunit-fixture/fixture.js"></script>
QUnit.fixture
- parameter : (String) html
- return : (NodeList) childNodes for
#fixture
function plusWidth10px( id ){
var currentWidth = document.getElementById( id ).style.width;
document.getElementById( id ).style.width = currentWidth + 10;
}
QUnit.test( "QUnit.fixture should be return childeNodes of #qunit-fixture", function ( assert ) {
var fixtureNodes = QUnit.fixture( "<div id='test' style='width:10px'></div>" );
plusWidth10px("test");
assert.equal( fixtureNodes[0].style.width, "20px" );
});