Skip to content
This repository has been archived by the owner on Feb 12, 2018. It is now read-only.

Commit

Permalink
Finished up jQuery test
Browse files Browse the repository at this point in the history
  • Loading branch information
twolfson committed Jan 9, 2013
1 parent 71e2a5e commit 685e7f3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion test/Builder.jquery.html
Expand Up @@ -10,7 +10,7 @@
<script src="../libs/qunit/qunit.js"></script>
<!-- Load local lib and tests. -->
<script src="../dist/Builder.jquery.js"></script>
<script src="Builder_test.js"></script>
<script src="Builder_test.jquery.js"></script>
<!-- Removing access to jQuery and $. But it'll still be available as _$, if
you REALLY want to mess around with jQuery in the console. REMEMBER WE
ARE TESTING A PLUGIN HERE, THIS HELPS ENSURE BEST PRACTICES. REALLY. -->
Expand Down
17 changes: 15 additions & 2 deletions test/Builder_test.jquery.js
Expand Up @@ -24,11 +24,24 @@
module('Builder#jquery');

test('A template rendered by a jQuery Builder returns a valid jQuery collection and the expected elements', function() {
expect(2);
var template = '<div><span>Hello</span><button>World</button></div><div>!</div>',
expect(7);

// Render the content via Builder
var template = '<div><span>Hello</span> <article>World</article></div><section>!</section>',
$content = Builder(template);

// Compare properties of the $content
strictEqual($content.length, 2, 'has a length of 2');
ok($content instanceof $, 'is a jQuery object');
strictEqual($content.text(), 'Hello World!', 'has proper text');

// Hard comparison for first elemnt
ok($content.eq(0).is('div'), 'has div for first element');
strictEqual($content.eq(0).html(), '<span>Hello</span> <article>World</article>', 'has proper first element HTML');

// Hard comparison for second elemnt
ok($content.eq(1).is('section'), 'has section for second element');
strictEqual($content.eq(1).html(), '!', 'has proper second element HTML');
});

}(jQuery));

0 comments on commit 685e7f3

Please sign in to comment.