Testing function that creates a list of DOM components
<p>I have a function which creates an Array of components.  Each component is an outer div with a few inner divs.</p>

<pre><code>function createDivs(quizQuestions) {
    var returnElements = new Array();
    $.each(quizQuestions.questions, function(i, val){

    // create the div.
    quizDiv = $('&lt;div class="questionContainer radius"&gt;')
    questionDiv = $('&lt;div class="question"&gt;&lt;b&gt;&lt;span&gt;QuestionText&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;');
    quizDiv.append(questionDiv);

    // Now change the question div text.
    questionDiv.text = val.question;
    answerDiv = $('&lt;div class="answers"&gt;');
    // ...
    // ...
    // Now the answers.
    questionDiv.append(answerDiv);
    returnElements[i] = quizDiv;
});
return returnElements; 
</code></pre>

<p>I pass JSON such as:</p>

<pre><code>   {questions:[{"question":"Name the best Rugby team?",
   "answers":["Leinster", "Munster", "Ulster", "Connaught"],
   "correct_answer":"Leinster"},
   {"question":"Name the best DJ?",
   "answers":["Warren K", "Pressure", "Digweed", "Sasha"],
   "correct_answer":"Leinster"}]};
</code></pre>

<p>I'd like to write a simpe unit test so that I could test the array of div returned made sense</p>

<p>Any tips?</p>

<p>Also, are my better to return a DOM component or just text?  The latter would be easier to test.</p>

<p>Thanks.</p>
