example qunit tests

already has qunit and its css linked already. sample test provided. useful as a template.

by twistedinferno

HTML

<link rel="stylesheet" href="http://code.jquery.com/qunit/git/qunit.css">
<script src="http://code.jquery.com/qunit/git/qunit.js"></script>
<h1 id="qunit-header">Unit Tests</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture"></div>

JavaScript

function Stadium() {
    this.lightEastStand = false;
    this.lightWestStand = false;
    this.lightNorthStand = false;
    this.lightSouthStand = false;
}

Stadium.prototype = {
    _switchOnAllLights: function () {
        this.lightEastStand = true;
        this.lightNorthStand = true;
        this.lightSouthStand = true;
        this.lightWestStand = true;
    },

    openDoors: function () {
        //openEastDoor();
        //openbackDoor();
        this._switchOnAllLights();
    },

    startMatch: function () {
        //startCameras()
        //displayScoreBoard()
        this._switchOnAllLights();
    },

    duskStarts: function () {
        //lockMainEntrance();
        this._switchOnAllLights();
    }
}


test("openDoors", function() {
    var myStadium = new Stadium();
    myStadium.duskStarts();          

    //duplication, is this ok?
    equal( myStadium.lightEastStand , true );
    equal( myStadium.lightNorthStand , true );
    equal( myStadium.lightSouthStand , true );
    equal( myStadium.lightWestStand , true );
}); 

test("startMatch", function() {
    var myStadium = new Stadium();
    myStadium.startMatch();          

    //duplication, is this ok?
    equal( myStadium.lightEastStand , true );
    equal( myStadium.lightNorthStand , true );
    equal( myStadium.lightSouthStand , true );
    equal( myStadium.lightWestStand , true );
}); 

test("duskStarts", function() {
    var myStadium = new Stadium();
    myStadium.duskStarts();          

    //duplication, is this ok?
    equal( myStadium.lightEastStand , true );
    equal( myStadium.lightNorthStand , true );
    equal( myStadium.lightSouthStand , true );
    equal( myStadium.lightWestStand , true );
});