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

Commit eccd9bf

Browse files
committed
add much needed whitespace to jqLiteSpec.js
can we agree to put more white space into our code? I follow there rules for specs: - 1 blank line between sections of nontrivial it block - 2 blank lines between it blocks - 2 blank lines between describe blocks - 2 blank lines between beforeEach and afterEach - no blank line between describe and the first child it - no blank lines between two or more closing }); lines
1 parent 2d9dd1c commit eccd9bf

File tree

1 file changed

+58
-3
lines changed

1 file changed

+58
-3
lines changed

test/jqLiteSpec.js

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
describe('jqLite', function(){
2-
var scope;
3-
var a, b, c;
2+
var scope, a, b, c;
3+
44
beforeEach(function(){
55
a = jqLite('<div>A</div>')[0];
66
b = jqLite('<div>B</div>')[0];
77
c = jqLite('<div>C</div>')[0];
88
});
99

10+
1011
beforeEach(function(){
1112
scope = angular.scope();
1213
this.addMatchers({
@@ -28,12 +29,14 @@ describe('jqLite', function(){
2829
});
2930
});
3031

32+
3133
afterEach(function(){
3234
dealoc(a);
3335
dealoc(b);
3436
dealoc(c);
3537
});
3638

39+
3740
describe('construction', function(){
3841
it('should allow construction with text node', function(){
3942
var text = a.firstChild;
@@ -42,32 +45,37 @@ describe('jqLite', function(){
4245
expect(selected[0]).toEqual(text);
4346
});
4447

48+
4549
it('should allow construction with html', function(){
4650
var nodes = jqLite('<div>1</div><span>2</span>');
4751
expect(nodes.length).toEqual(2);
4852
expect(nodes[0].innerHTML).toEqual('1');
4953
expect(nodes[1].innerHTML).toEqual('2');
5054
});
5155

56+
5257
it('should allow creation of comment tags', function() {
5358
var nodes = jqLite('<!-- foo -->');
5459
expect(nodes.length).toBe(1);
5560
expect(nodes[0].nodeType).toBe(8);
5661
});
5762

63+
5864
it('should allow creation of script tags', function() {
5965
var nodes = jqLite('<script></script>');
6066
expect(nodes.length).toBe(1);
6167
expect(nodes[0].tagName.toUpperCase()).toBe('SCRIPT');
6268
});
6369

70+
6471
it('should wrap document fragment', function() {
6572
var fragment = jqLite(document.createDocumentFragment());
6673
expect(fragment.length).toBe(1);
6774
expect(fragment[0].nodeType).toBe(11);
6875
});
6976
});
7077

78+
7179
describe('scope', function() {
7280
it('should retrieve scope attached to the current element', function() {
7381
var element = jqLite('<i>foo</i>');
@@ -76,6 +84,7 @@ describe('jqLite', function(){
7684
dealoc(element);
7785
});
7886

87+
7988
it('should walk up the dom to find scope', function() {
8089
var element = jqLite('<ul><li><p><b>deep deep</b><p></li></ul>');
8190
var deepChild = jqLite(element[0].getElementsByTagName('b')[0]);
@@ -84,6 +93,7 @@ describe('jqLite', function(){
8493
dealoc(element);
8594
});
8695

96+
8797
it('should return undefined when no scope was found', function() {
8898
var element = jqLite('<ul><li><p><b>deep deep</b><p></li></ul>');
8999
var deepChild = jqLite(element[0].getElementsByTagName('b')[0]);
@@ -92,6 +102,7 @@ describe('jqLite', function(){
92102
});
93103
});
94104

105+
95106
describe('data', function(){
96107
it('should set and get ande remove data', function(){
97108
var selected = jqLite([a, b, c]);
@@ -115,6 +126,7 @@ describe('jqLite', function(){
115126
});
116127
});
117128

129+
118130
describe('attr', function(){
119131
it('shoul read wirite and remove attr', function(){
120132
var selector = jqLite([a, b]);
@@ -136,13 +148,18 @@ describe('jqLite', function(){
136148
expect(jqLite(b).attr('prop')).toBeFalsy();
137149
});
138150
});
151+
152+
139153
describe('class', function(){
154+
140155
describe('hasClass', function(){
141156
it('should check class', function(){
142157
var selector = jqLite([a, b]);
143158
expect(selector.hasClass('abc')).toEqual(false);
144159
});
145160
});
161+
162+
146163
describe('addClass', function(){
147164
it('should allow adding of class', function(){
148165
var selector = jqLite([a, b]);
@@ -151,6 +168,8 @@ describe('jqLite', function(){
151168
expect(jqLite(b).hasClass('abc')).toEqual(true);
152169
});
153170
});
171+
172+
154173
describe('toggleClass', function(){
155174
it('should allow toggling of class', function(){
156175
var selector = jqLite([a, b]);
@@ -172,6 +191,8 @@ describe('jqLite', function(){
172191

173192
});
174193
});
194+
195+
175196
describe('removeClass', function(){
176197
it('should allow removal of class', function(){
177198
var selector = jqLite([a, b]);
@@ -182,6 +203,8 @@ describe('jqLite', function(){
182203
});
183204
});
184205
});
206+
207+
185208
describe('css', function(){
186209
it('should set and read css', function(){
187210
var selector = jqLite([a, b]);
@@ -203,12 +226,15 @@ describe('jqLite', function(){
203226
expect(jqLite(b).css('prop')).toBeFalsy();
204227
});
205228
});
229+
230+
206231
describe('text', function(){
207232
it('should return null on empty', function(){
208233
expect(jqLite().length).toEqual(0);
209234
expect(jqLite().text()).toEqual('');
210235
});
211236

237+
212238
it('should read/write value', function(){
213239
var element = jqLite('<div>abc</div>');
214240
expect(element.length).toEqual(1);
@@ -218,6 +244,8 @@ describe('jqLite', function(){
218244
expect(element.text()).toEqual('xyz');
219245
});
220246
});
247+
248+
221249
describe('val', function(){
222250
it('should read, write value', function(){
223251
var input = jqLite('<input type="text"/>');
@@ -226,12 +254,15 @@ describe('jqLite', function(){
226254
expect(input.val()).toEqual('abc');
227255
});
228256
});
257+
258+
229259
describe('html', function(){
230260
it('should return null on empty', function(){
231261
expect(jqLite().length).toEqual(0);
232262
expect(jqLite().html()).toEqual(null);
233263
});
234264

265+
235266
it('should read/write value', function(){
236267
var element = jqLite('<div>abc</div>');
237268
expect(element.length).toEqual(1);
@@ -242,6 +273,7 @@ describe('jqLite', function(){
242273
});
243274
});
244275

276+
245277
describe('bind', function(){
246278
it('should bind to window on hashchange', function(){
247279
if (jqLite.fn) return; // don't run in jQuery
@@ -272,6 +304,7 @@ describe('jqLite', function(){
272304
dealoc(jWindow);
273305
});
274306

307+
275308
it('should bind to all elements and return functions', function(){
276309
var selected = jqLite([a, b]);
277310
var log = '';
@@ -285,20 +318,25 @@ describe('jqLite', function(){
285318
});
286319
});
287320

321+
288322
describe('replaceWith', function(){
289323
it('should replaceWith', function(){
290324
var root = jqLite('<div>').html('before-<div></div>after');
291325
var div = root.find('div');
292326
expect(div.replaceWith('<span>span-</span><b>bold-</b>')).toEqual(div);
293327
expect(root.text()).toEqual('before-span-bold-after');
294328
});
329+
330+
295331
it('should replaceWith text', function(){
296332
var root = jqLite('<div>').html('before-<div></div>after');
297333
var div = root.find('div');
298334
expect(div.replaceWith('text-')).toEqual(div);
299335
expect(root.text()).toEqual('before-text-after');
300336
});
301337
});
338+
339+
302340
describe('children', function(){
303341
it('should select non-text children', function(){
304342
var root = jqLite('<div>').html('before-<div></div>after-<span></span>');
@@ -307,6 +345,8 @@ describe('jqLite', function(){
307345
expect(root.children()).toJqEqual([div, span]);
308346
});
309347
});
348+
349+
310350
describe('append', function(){
311351
it('should append', function(){
312352
var root = jqLite('<div>');
@@ -324,6 +364,8 @@ describe('jqLite', function(){
324364
expect(root.children().length).toBe(0);
325365
});
326366
});
367+
368+
327369
describe('remove', function(){
328370
it('should remove', function(){
329371
var root = jqLite('<div><span>abc</span></div>');
@@ -332,20 +374,26 @@ describe('jqLite', function(){
332374
expect(root.html()).toEqual('');
333375
});
334376
});
377+
378+
335379
describe('after', function(){
336380
it('should after', function(){
337381
var root = jqLite('<div><span></span></div>');
338382
var span = root.find('span');
339383
expect(span.after('<i></i><b></b>')).toEqual(span);
340384
expect(root.html().toLowerCase()).toEqual('<span></span><i></i><b></b>');
341385
});
386+
387+
342388
it('should allow taking text', function(){
343389
var root = jqLite('<div><span></span></div>');
344390
var span = root.find('span');
345391
span.after('abc');
346392
expect(root.html().toLowerCase()).toEqual('<span></span>abc');
347393
});
348394
});
395+
396+
349397
describe('parent', function(){
350398
it('should return parent or an empty set when no parent', function(){
351399
var parent = jqLite('<div><p>abc</p></div>'),
@@ -357,11 +405,15 @@ describe('jqLite', function(){
357405
expect(child.parent().length).toBe(1);
358406
expect(child.parent()[0]).toBe(parent[0]);
359407
});
408+
409+
360410
it('should return empty set when no parent', function(){
361411
var element = jqLite('<div>abc</div>');
362412
expect(element.parent()).toBeTruthy();
363413
expect(element.parent().length).toEqual(0);
364414
});
415+
416+
365417
it('should return empty jqLite object when parent is a document fragment', function() {
366418
//this is quite unfortunate but jQuery 1.5.1 behaves this way
367419
var fragment = document.createDocumentFragment(),
@@ -372,6 +424,8 @@ describe('jqLite', function(){
372424
expect(child.parent().length).toBe(0);
373425
});
374426
});
427+
428+
375429
describe('next', function(){
376430
it('should return next sibling', function(){
377431
var element = jqLite('<div><b>b</b><i>i</i></div>');
@@ -380,6 +434,8 @@ describe('jqLite', function(){
380434
expect(b.next()).toJqEqual([i]);
381435
});
382436
});
437+
438+
383439
describe('find', function(){
384440
it('should find child by name', function(){
385441
var root = jqLite('<div><div>text</div></div>');
@@ -388,5 +444,4 @@ describe('jqLite', function(){
388444
expect(innerDiv.html()).toEqual('text');
389445
});
390446
});
391-
392447
});

0 commit comments

Comments
 (0)