0.0.3 • Published 10 years ago
qunit-fixture v0.0.3
qunit-fixture
This utility is fixture for QUnit.
Why use it?
If you have to use fixture It has some ways.
1. Add html in #fixture.
<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.
2. Append html using append or ....
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.
How to use it?
install
npm install qunit-fixtureor
bower install qunit-fixturesetup
<script src="jquery.js"></script>
<script src="../bower_components/qunit-fixture/fixture.js"></script>method
QUnit.fixture
- parameter : (String) html
- return : (NodeList) childNodes for
#fixture
sample
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" );
});