Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 2d9dd1c

Browse files
committed
add specs for jqLite wrapping/node creation
tests cover: - creating comment tags from a string - creating script tag from a string - wrapping document fragment
1 parent a2c4271 commit 2d9dd1c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/jqLiteSpec.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,31 @@ describe('jqLite', function(){
4141
expect(selected.length).toEqual(1);
4242
expect(selected[0]).toEqual(text);
4343
});
44+
4445
it('should allow construction with html', function(){
4546
var nodes = jqLite('<div>1</div><span>2</span>');
4647
expect(nodes.length).toEqual(2);
4748
expect(nodes[0].innerHTML).toEqual('1');
4849
expect(nodes[1].innerHTML).toEqual('2');
4950
});
51+
52+
it('should allow creation of comment tags', function() {
53+
var nodes = jqLite('<!-- foo -->');
54+
expect(nodes.length).toBe(1);
55+
expect(nodes[0].nodeType).toBe(8);
56+
});
57+
58+
it('should allow creation of script tags', function() {
59+
var nodes = jqLite('<script></script>');
60+
expect(nodes.length).toBe(1);
61+
expect(nodes[0].tagName.toUpperCase()).toBe('SCRIPT');
62+
});
63+
64+
it('should wrap document fragment', function() {
65+
var fragment = jqLite(document.createDocumentFragment());
66+
expect(fragment.length).toBe(1);
67+
expect(fragment[0].nodeType).toBe(11);
68+
});
5069
});
5170

5271
describe('scope', function() {

0 commit comments

Comments
 (0)