'use strict'; describe('jqLite', function() { var scope, a, b, c; beforeEach(module(provideLog)); beforeEach(function() { a = jqLite('
A
')[0]; b = jqLite('
B
')[0]; c = jqLite('
C
')[0]; }); beforeEach(inject(function($rootScope) { scope = $rootScope; this.addMatchers({ toJqEqual: function(expected) { var msg = "Unequal length"; this.message = function() {return msg;}; var value = this.actual && expected && this.actual.length == expected.length; for (var i = 0; value && i < expected.length; i++) { var actual = jqLite(this.actual[i])[0]; var expect = jqLite(expected[i])[0]; value = value && equals(expect, actual); msg = "Not equal at index: " + i + " - Expected: " + expect + " - Actual: " + actual; } return value; } }); })); afterEach(function() { dealoc(a); dealoc(b); dealoc(c); }); it('should be jqLite when jqLiteMode is on, otherwise jQuery', function() { expect(jqLite).toBe(_jqLiteMode ? JQLite : _jQuery); }); describe('construction', function() { it('should allow construction with text node', function() { var text = a.firstChild; var selected = jqLite(text); expect(selected.length).toEqual(1); expect(selected[0]).toEqual(text); }); it('should allow construction with html', function() { var nodes = jqLite('
1
2'); expect(nodes[0].parentNode).toBeDefined(); expect(nodes[0].parentNode.nodeType).toBe(11); /** Document Fragment **/ expect(nodes[0].parentNode).toBe(nodes[1].parentNode); expect(nodes.length).toEqual(2); expect(nodes[0].innerHTML).toEqual('1'); expect(nodes[1].innerHTML).toEqual('2'); }); it('should allow construction of html with leading whitespace', function() { var nodes = jqLite(' \n\r \r\n
1
2'); expect(nodes[0].parentNode).toBeDefined(); expect(nodes[0].parentNode.nodeType).toBe(11); /** Document Fragment **/ expect(nodes[0].parentNode).toBe(nodes[1].parentNode); expect(nodes.length).toBe(2); expect(nodes[0].innerHTML).toBe('1'); expect(nodes[1].innerHTML).toBe('2'); }); it('should allow creation of comment tags', function() { var nodes = jqLite(''); expect(nodes.length).toBe(1); expect(nodes[0].nodeType).toBe(8); }); it('should allow creation of script tags', function() { var nodes = jqLite(''); expect(nodes.length).toBe(1); expect(nodes[0].tagName.toUpperCase()).toBe('SCRIPT'); }); it('should wrap document fragment', function() { var fragment = jqLite(document.createDocumentFragment()); expect(fragment.length).toBe(1); expect(fragment[0].nodeType).toBe(11); }); it('should allow construction of