This utility is fixture for QUnit.
JavaScript HTML
Latest commit fca0693 Feb 11, 2016 @mixed Version up
Permalink
Failed to load latest commit information.
src init Feb 10, 2016
test init Feb 10, 2016
.gitignore Add ignore type Feb 11, 2016
.jscsrc init Feb 10, 2016
.jshintrc init Feb 10, 2016
Gruntfile.js init Feb 10, 2016
LICENSE Initial commit Feb 7, 2016
README.md Update code type Feb 10, 2016
bower.json init Feb 10, 2016
package.json Version up Feb 11, 2016

README.md

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-fixture

or

bower install qunit-fixture

setup

<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" );
});