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

Commit acb4338

Browse files
committed
style(widgetsSpec): ws, unused variables, etc
1 parent cd9a7b9 commit acb4338

File tree

1 file changed

+42
-17
lines changed

1 file changed

+42
-17
lines changed

test/widgetsSpec.js

+42-17
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
describe('widget', function() {
4-
describe('ng:switch', inject(function($rootScope, $compile) {
4+
describe('ng:switch', function() {
55
it('should switch on value change', inject(function($rootScope, $compile) {
66
var element = $compile(
77
'<ng:switch on="select">' +
@@ -26,7 +26,7 @@ describe('widget', function() {
2626
$rootScope.$apply();
2727
expect(element.text()).toEqual('true:misko');
2828
}));
29-
29+
3030

3131
it('should switch on switch-when-default', inject(function($rootScope, $compile) {
3232
var element = $compile(
@@ -41,7 +41,7 @@ describe('widget', function() {
4141
expect(element.text()).toEqual('one');
4242
}));
4343

44-
44+
4545
it('should call change on switch', inject(function($rootScope, $compile) {
4646
var element = $compile(
4747
'<ng:switch on="url" change="name=\'works\'">' +
@@ -52,7 +52,7 @@ describe('widget', function() {
5252
expect($rootScope.name).toEqual(undefined);
5353
expect(element.text()).toEqual('works');
5454
}));
55-
}));
55+
});
5656

5757

5858
describe('ng:include', inject(function($rootScope, $compile) {
@@ -149,6 +149,7 @@ describe('widget', function() {
149149
expect($rootScope.$$childHead).toBeFalsy();
150150
}));
151151

152+
152153
it('should do xhr request and cache it',
153154
inject(function($rootScope, $httpBackend, $compile, $browser) {
154155
var element = $compile('<ng:include src="url"></ng:include>')($rootScope);
@@ -170,6 +171,7 @@ describe('widget', function() {
170171
dealoc($rootScope);
171172
}));
172173

174+
173175
it('should clear content when error during xhr request',
174176
inject(function($httpBackend, $compile, $rootScope) {
175177
var element = $compile('<ng:include src="url">content</ng:include>')($rootScope);
@@ -182,6 +184,7 @@ describe('widget', function() {
182184
expect(element.text()).toBe('');
183185
}));
184186

187+
185188
it('should be async even if served from cache', inject(
186189
putIntoCache('myUrl', 'my partial'),
187190
function($rootScope, $compile, $browser) {
@@ -200,6 +203,7 @@ describe('widget', function() {
200203
expect(element.text()).toBe('my partial');
201204
}));
202205

206+
203207
it('should discard pending xhr callbacks if a new template is requested before the current ' +
204208
'finished loading', inject(function($rootScope, $compile, $httpBackend) {
205209
var element = jqLite("<ng:include src='templateUrl'></ng:include>"),
@@ -226,7 +230,7 @@ describe('widget', function() {
226230
}));
227231

228232

229-
describe('a', inject(function($rootScope, $compile) {
233+
describe('a', function() {
230234
it('should prevent default action to be executed when href is empty',
231235
inject(function($rootScope, $compile) {
232236
var orgLocation = document.location.href,
@@ -261,10 +265,10 @@ describe('widget', function() {
261265

262266
expect(document.location.href).toEqual(orgLocation);
263267
}));
264-
}));
268+
});
265269

266270

267-
describe('@ng:repeat', inject(function($rootScope, $compile) {
271+
describe('@ng:repeat', function() {
268272
it('should ng:repeat over array', inject(function($rootScope, $compile) {
269273
var element = $compile(
270274
'<ul>' +
@@ -292,6 +296,7 @@ describe('widget', function() {
292296
expect(element.text()).toEqual('brad;');
293297
}));
294298

299+
295300
it('should ng:repeat over object', inject(function($rootScope, $compile) {
296301
var element = $compile(
297302
'<ul>' +
@@ -302,6 +307,7 @@ describe('widget', function() {
302307
expect(element.text()).toEqual('misko:swe;shyam:set;');
303308
}));
304309

310+
305311
it('should not ng:repeat over parent properties', inject(function($rootScope, $compile) {
306312
var Class = function() {};
307313
Class.prototype.abc = function() {};
@@ -317,6 +323,7 @@ describe('widget', function() {
317323
expect(element.text()).toEqual('name:value;');
318324
}));
319325

326+
320327
it('should error on wrong parsing of ng:repeat', inject(function($rootScope, $compile, $log) {
321328
expect(function() {
322329
var element = $compile('<ul><li ng:repeat="i dont parse"></li></ul>')($rootScope);
@@ -325,6 +332,7 @@ describe('widget', function() {
325332
$log.error.logs.shift();
326333
}));
327334

335+
328336
it('should expose iterator offset as $index when iterating over arrays',
329337
inject(function($rootScope, $compile) {
330338
var element = $compile(
@@ -336,6 +344,7 @@ describe('widget', function() {
336344
expect(element.text()).toEqual('misko0|shyam1|frodo2|');
337345
}));
338346

347+
339348
it('should expose iterator offset as $index when iterating over objects',
340349
inject(function($rootScope, $compile) {
341350
var element = $compile(
@@ -347,6 +356,7 @@ describe('widget', function() {
347356
expect(element.text()).toEqual('frodo:f0|misko:m1|shyam:s2|');
348357
}));
349358

359+
350360
it('should expose iterator position as $position when iterating over arrays',
351361
inject(function($rootScope, $compile) {
352362
var element = $compile(
@@ -367,6 +377,7 @@ describe('widget', function() {
367377
expect(element.text()).toEqual('misko:first|shyam:last|');
368378
}));
369379

380+
370381
it('should expose iterator position as $position when iterating over objects',
371382
inject(function($rootScope, $compile) {
372383
var element = $compile(
@@ -384,6 +395,7 @@ describe('widget', function() {
384395
expect(element.text()).toEqual('misko:m:first|shyam:s:last|');
385396
}));
386397

398+
387399
it('should ignore $ and $$ properties', inject(function($rootScope, $compile) {
388400
var element = $compile('<ul><li ng:repeat="i in items">{{i}}|</li></ul>')($rootScope);
389401
$rootScope.items = ['a', 'b', 'c'];
@@ -394,6 +406,7 @@ describe('widget', function() {
394406
expect(element.text()).toEqual('a|b|c|');
395407
}));
396408

409+
397410
it('should repeat over nested arrays', inject(function($rootScope, $compile) {
398411
var element = $compile(
399412
'<ul>' +
@@ -407,6 +420,7 @@ describe('widget', function() {
407420
expect(element.text()).toEqual('a|b|Xc|d|X');
408421
}));
409422

423+
410424
it('should ignore non-array element properties when iterating over an array',
411425
inject(function($rootScope, $compile) {
412426
var element = $compile('<ul><li ng:repeat="item in array">{{item}}|</li></ul>')($rootScope);
@@ -418,6 +432,7 @@ describe('widget', function() {
418432
expect(element.text()).toBe('a|b|c|');
419433
}));
420434

435+
421436
it('should iterate over non-existent elements of a sparse array',
422437
inject(function($rootScope, $compile) {
423438
var element = $compile('<ul><li ng:repeat="item in array">{{item}}|</li></ul>')($rootScope);
@@ -429,6 +444,7 @@ describe('widget', function() {
429444
expect(element.text()).toBe('a|b|||c||d|');
430445
}));
431446

447+
432448
it('should iterate over all kinds of types', inject(function($rootScope, $compile) {
433449
var element = $compile('<ul><li ng:repeat="item in array">{{item}}|</li></ul>')($rootScope);
434450
$rootScope.array = ['a', 1, null, undefined, {}];
@@ -456,7 +472,8 @@ describe('widget', function() {
456472
lis = element.find('li');
457473
}));
458474

459-
it('should preserve the order of elements', inject(function($rootScope, $compile) {
475+
476+
it('should preserve the order of elements', inject(function($rootScope) {
460477
$rootScope.items = [a, c, d];
461478
$rootScope.$digest();
462479
var newElements = element.find('li');
@@ -465,7 +482,8 @@ describe('widget', function() {
465482
expect(newElements[2]).not.toEqual(lis[1]);
466483
}));
467484

468-
it('should support duplicates', inject(function($rootScope, $compile) {
485+
486+
it('should support duplicates', inject(function($rootScope) {
469487
$rootScope.items = [a, a, b, c];
470488
$rootScope.$digest();
471489
var newElements = element.find('li');
@@ -490,8 +508,9 @@ describe('widget', function() {
490508
expect(newElements[3]).toEqual(lis[3]);
491509
}));
492510

511+
493512
it('should remove last item when one duplicate instance is removed',
494-
inject(function($rootScope, $compile) {
513+
inject(function($rootScope) {
495514
$rootScope.items = [a, a, a];
496515
$rootScope.$digest();
497516
lis = element.find('li');
@@ -504,8 +523,9 @@ describe('widget', function() {
504523
expect(newElements[1]).toEqual(lis[1]);
505524
}));
506525

526+
507527
it('should reverse items when the collection is reversed',
508-
inject(function($rootScope, $compile) {
528+
inject(function($rootScope) {
509529
$rootScope.items = [a, b, c];
510530
$rootScope.$digest();
511531
lis = element.find('li');
@@ -519,7 +539,7 @@ describe('widget', function() {
519539
expect(newElements[2]).toEqual(lis[0]);
520540
}));
521541
});
522-
}));
542+
});
523543

524544

525545
describe('@ng:non-bindable', function() {
@@ -568,6 +588,7 @@ describe('widget', function() {
568588
expect(element.text()).toEqual('angular is da best');
569589
}));
570590

591+
571592
it('should remove all content when location changes to an unknown route',
572593
inject(function($rootScope, $compile, $location, $httpBackend, $route) {
573594
$route.when('/foo', {template: 'myUrl1'});
@@ -583,6 +604,7 @@ describe('widget', function() {
583604
expect($rootScope.$element.text()).toEqual('');
584605
}));
585606

607+
586608
it('should chain scopes and propagate evals to the child scope',
587609
inject(function($rootScope, $compile, $location, $httpBackend, $route) {
588610
$route.when('/foo', {template: 'myUrl1'});
@@ -599,6 +621,7 @@ describe('widget', function() {
599621
expect($rootScope.$element.text()).toEqual('new parent');
600622
}));
601623

624+
602625
it('should be possible to nest ng:view in ng:include', inject(function() {
603626
// TODO(vojta): refactor this test
604627
var injector = angular.injector('ng', 'ngMock');
@@ -624,6 +647,7 @@ describe('widget', function() {
624647
dealoc(myApp);
625648
}));
626649

650+
627651
it('should initialize view template after the view controller was initialized even when ' +
628652
'templates were cached',
629653
inject(function($rootScope, $compile, $location, $httpBackend, $route, $browser) {
@@ -662,6 +686,7 @@ describe('widget', function() {
662686
expect($rootScope.log).toEqual(['parent', 'init', 'child']);
663687
}));
664688

689+
665690
it('should discard pending xhr callbacks if a new route is requested before the current ' +
666691
'finished loading', inject(function($route, $rootScope, $location, $httpBackend) {
667692
// this is a test for a bad race condition that affected feedback
@@ -682,6 +707,7 @@ describe('widget', function() {
682707
expect($rootScope.$element.text()).toEqual('2');
683708
}));
684709

710+
685711
it('should clear the content when error during xhr request',
686712
inject(function($route, $location, $rootScope, $httpBackend) {
687713
$route.when('/foo', {controller: noop, template: 'myUrl1'});
@@ -696,6 +722,7 @@ describe('widget', function() {
696722
expect($rootScope.$element.text()).toBe('');
697723
}));
698724

725+
699726
it('should be async even if served from cache',
700727
inject(function($route, $rootScope, $location, $templateCache, $browser) {
701728
$templateCache.put('myUrl1', [200, 'my partial', {}]);
@@ -717,7 +744,6 @@ describe('widget', function() {
717744

718745
describe('ng:pluralize', function() {
719746

720-
721747
describe('deal with pluralized strings without offset', function() {
722748
var element;
723749
beforeEach(inject(function($rootScope, $compile) {
@@ -729,7 +755,8 @@ describe('widget', function() {
729755
'</ng:pluralize>')($rootScope);
730756
}));
731757

732-
it('should show single/plural strings', inject(function($rootScope, $compile) {
758+
759+
it('should show single/plural strings', inject(function($rootScope) {
733760
$rootScope.email = 0;
734761
$rootScope.$digest();
735762
expect(element.text()).toBe('You have no new email');
@@ -768,8 +795,7 @@ describe('widget', function() {
768795
}));
769796

770797

771-
it('should show single/plural strings with mal-formed inputs',
772-
inject(function($rootScope, $compile) {
798+
it('should show single/plural strings with mal-formed inputs', inject(function($rootScope) {
773799
$rootScope.email = '';
774800
$rootScope.$digest();
775801
expect(element.text()).toBe('');
@@ -845,4 +871,3 @@ describe('widget', function() {
845871
});
846872
});
847873
});
848-

0 commit comments

Comments
 (0)