example qunit tests

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

by ernestohs

HTML

<link rel="stylesheet" href="http://code.jquery.com/qunit/git/qunit.css">
<script src="http://code.jquery.com/qunit/git/qunit.js"></script>
<p align="justify">Have the function LetterChanges(str) take the str parameter being passed and modify it using the following algorithm. Replace every letter in the string with the letter following it in the alphabet (ie. c becomes d, z becomes a). Then capitalize every vowel in this new string (a, e, i, o, u) and finally return this modified string. Use the Parameter Testing feature in the box below to test your code with different arguments.</p>
<BR/>
<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

var LetterChanges = function(str) {
    return str;    
};


test("First test case", function() {
    var value = "replace!*";
    var expected = "sFqmzdF!*";
    var actual = LetterChanges(value);
    equal(actual, expected, "We expect value to be " + expected);
});

test("Second test case", function() {
    var value = "beautiful^";
    var expected = "cFzvUjgvm^";
    var actual = LetterChanges(value);
    equal(actual, expected, "We expect value to be " + expected);
});

test("Third test case", function() {
    var value = "123456789ae";
    var expected = "123456789zF";
    var actual = LetterChanges(value);
    equal(actual, expected, "We expect value to be " + expected);
});

test("Fourth test case", function() {
    var value = "this long cake@&";
    var expected = "UIjt mpOh dzlF@&";
    var actual = LetterChanges(value);
    equal(actual, expected, "We expect value to be " + expected);
});

test("Fifth test case", function() {
    var value = "a b c dee";
    var expected = "z c d EFF";
    var actual = LetterChanges(value);
    equal(actual, expected, "We expect value to be " + expected);
});


test("Sixth test case", function() {
    var value = "a confusing /:sentence:/[ this is not!!!!!!!~";
    var expected = "z dpOgvtjOh /:tFOUFOdF:/[ UIjt jt OpU!!!!!!!~";
    var actual = LetterChanges(value);
    equal(actual, expected, "We expect value to be " + expected);
});