Skip to content

Commit

Permalink
Updated some list creation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
javve committed Apr 24, 2012
1 parent 2f5e52e commit 544b861
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 5 deletions.
29 changes: 29 additions & 0 deletions tests/list-creation.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,34 @@ <h2 id="qunit-userAgent"></h2>
<ul class="list">
</ul>
</div>


<div id="list-broken" style="visibility:hidden;">
<input class="search" />
<ul class="list">
<li>
<span class="id">1</span>
<span class="name">John Resig</span>
</li>
<li>
<span class="id">2</span>
<span class="name">John Resig</span>
</li>
<li>
<span class="id">3</span>
</li>
</ul>
</div>

<div id="list-broken-item" style="visibility:hidden;">
<input class="search" />
<ul class="list">
</ul>
</div>
<ul style="display:none;">
<li id="itemTemplateBroken">
<span class="id">1</span>
</li>
</ul>
</body>
</html>
28 changes: 23 additions & 5 deletions tests/list-creation.tests.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module("List.js Creation Variants test");
var theList1,theList2,theList3;

var listItems = [
{ id: 1, name: "Ryan Dahl" },
Expand All @@ -18,7 +17,7 @@ test('Create List.js from existing list', function() {
var templates = {
valueNames: ['id', 'name']
};
theList1 = new List('list1', templates, listItems);
var theList1 = new List('list1', templates, listItems);
equals(theList1.size(), 11);
ok(true, "list created" );
});
Expand All @@ -28,7 +27,7 @@ test('Create List.js from existing list', function() {
valueNames: ['id', 'name'],
item: "itemTemplate"
};
theList2 = new List('list2', templates, listItems);
var theList2 = new List('list2', templates, listItems);
equals(theList2.size(), 10);
ok(true, "list created" );
});
Expand All @@ -38,7 +37,7 @@ test('Create List.js from existing list', function() {
valueNames: ['id', 'name'],
item: '<li id="itemTemplate"><span class="id">1</span><span class="name">John Resig</span></li>'
};
theList3 = new List('list3', templates, listItems);
var theList3 = new List('list3', templates, listItems);
equals(theList3.size(), 10);
ok(true, "list created" );
});
Expand All @@ -48,7 +47,26 @@ test('Create List.js with element instead of id', function() {
valueNames: ['id', 'name'],
item: '<li id="itemTemplate"><span class="id">1</span><span class="name">John Resig</span></li>'
};
theList3 = new List(ListJsHelpers.getByClass('list4', document.body, true), templates, listItems);
var theList3 = new List(ListJsHelpers.getByClass('list4', document.body, true), templates, listItems);
equals(theList3.size(), 10);
ok(true, "list created" );
});

test('Create List.js from existing list with missing markup', function() {
var templates = {
valueNames: ['id', 'name']
};
var theListBroken = new List('list-broken', templates);
equals(theListBroken.size(), 3);
deepEqual(theListBroken.get('id', 3).values(), { id: "3", name: "" });
ok(true, "list created" );
});
test('Create List.js from existing list witb broken template', function() {
var templates = {
valueNames: ['id', 'name'],
item: "itemTemplateBroken"
};
var brokenList = new List('list-broken-item', templates, listItems);
equals(brokenList.size(), 10);
ok(true, "list created" );
});

0 comments on commit 544b861

Please sign in to comment.