diff --git a/src/typeahead/test/typeahead-highlight.spec.js b/src/typeahead/test/typeahead-highlight.spec.js index 1a5aafc48d..1a5d8b1c5d 100644 --- a/src/typeahead/test/typeahead-highlight.spec.js +++ b/src/typeahead/test/typeahead-highlight.spec.js @@ -1,39 +1,38 @@ -describe('typeaheadHighlight', function () { - +describe('typeaheadHighlight', function() { var highlightFilter; beforeEach(module('ui.bootstrap.typeahead')); - beforeEach(inject(function (typeaheadHighlightFilter) { + beforeEach(inject(function(typeaheadHighlightFilter) { highlightFilter = typeaheadHighlightFilter; })); - it('should higlight a match', function () { + it('should higlight a match', function() { expect(highlightFilter('before match after', 'match')).toEqual('before match after'); }); - it('should higlight a match with mixed case', function () { + it('should higlight a match with mixed case', function() { expect(highlightFilter('before MaTch after', 'match')).toEqual('before MaTch after'); }); - it('should higlight all matches', function () { + it('should higlight all matches', function() { expect(highlightFilter('before MaTch after match', 'match')).toEqual('before MaTch after match'); }); - it('should do nothing if no match', function () { + it('should do nothing if no match', function() { expect(highlightFilter('before match after', 'nomatch')).toEqual('before match after'); }); - it('should do nothing if no or empty query', function () { + it('should do nothing if no or empty query', function() { expect(highlightFilter('before match after', '')).toEqual('before match after'); expect(highlightFilter('before match after', null)).toEqual('before match after'); expect(highlightFilter('before match after', undefined)).toEqual('before match after'); }); - it('issue 316 - should work correctly for regexp reserved words', function () { + it('issue 316 - should work correctly for regexp reserved words', function() { expect(highlightFilter('before (match after', '(match')).toEqual('before (match after'); }); - it('issue 1777 - should work correctly with numeric values', function () { + it('issue 1777 - should work correctly with numeric values', function() { expect(highlightFilter(123, '2')).toEqual('123'); }); }); diff --git a/src/typeahead/test/typeahead-parser.spec.js b/src/typeahead/test/typeahead-parser.spec.js index e6a7e536cd..f19aec5cfb 100644 --- a/src/typeahead/test/typeahead-parser.spec.js +++ b/src/typeahead/test/typeahead-parser.spec.js @@ -1,15 +1,14 @@ -describe('syntax parser', function () { - +describe('syntax parser', function() { var typeaheadParser, scope, filterFilter; beforeEach(module('ui.bootstrap.typeahead')); - beforeEach(inject(function (_$rootScope_, _filterFilter_, _typeaheadParser_) { + beforeEach(inject(function(_$rootScope_, _filterFilter_, _typeaheadParser_) { typeaheadParser = _typeaheadParser_; scope = _$rootScope_; filterFilter = _filterFilter_; })); - it('should parse the simplest array-based syntax', function () { + it('should parse the simplest array-based syntax', function() { scope.states = ['Alabama', 'California', 'Delaware']; var result = typeaheadParser.parse('state for state in states | filter:$viewValue'); @@ -22,8 +21,8 @@ describe('syntax parser', function () { expect(result.modelMapper(scope, locals)).toEqual('Alabama'); }); - it('should parse the simplest function-based syntax', function () { - scope.getStates = function ($viewValue) { + it('should parse the simplest function-based syntax', function() { + scope.getStates = function($viewValue) { return filterFilter(['Alabama', 'California', 'Delaware'], $viewValue); }; var result = typeaheadParser.parse('state for state in getStates($viewValue)'); @@ -38,7 +37,6 @@ describe('syntax parser', function () { }); it('should allow to specify custom model mapping that is used as a label as well', function () { - scope.states = [ {code:'AL', name:'Alabama'}, {code:'CA', name:'California'}, @@ -59,8 +57,7 @@ describe('syntax parser', function () { expect(result.modelMapper(scope, locals)).toEqual('Alabama'); }); - it('should allow to specify custom view and model mappers', function () { - + it('should allow to specify custom view and model mappers', function() { scope.states = [ {code:'AL', name:'Alabama'}, {code:'CA', name:'California'}, diff --git a/src/typeahead/test/typeahead-popup.spec.js b/src/typeahead/test/typeahead-popup.spec.js index 89c9f75e83..5b2b94ae3c 100644 --- a/src/typeahead/test/typeahead-popup.spec.js +++ b/src/typeahead/test/typeahead-popup.spec.js @@ -1,18 +1,16 @@ -describe('typeaheadPopup - result rendering', function () { - +describe('typeaheadPopup - result rendering', function() { var scope, $rootScope, $compile; beforeEach(module('ui.bootstrap.typeahead')); beforeEach(module('template/typeahead/typeahead-popup.html')); beforeEach(module('template/typeahead/typeahead-match.html')); - beforeEach(inject(function (_$rootScope_, _$compile_) { + beforeEach(inject(function(_$rootScope_, _$compile_) { $rootScope = _$rootScope_; scope = $rootScope.$new(); $compile = _$compile_; })); - it('should render initial results', function () { - + it('should render initial results', function() { scope.matches = ['foo', 'bar', 'baz']; scope.active = 1; @@ -26,8 +24,7 @@ describe('typeaheadPopup - result rendering', function () { expect(liElems.eq(2)).not.toHaveClass('active'); }); - it('should change active item on mouseenter', function () { - + it('should change active item on mouseenter', function() { scope.matches = ['foo', 'bar', 'baz']; scope.active = 1; @@ -44,8 +41,7 @@ describe('typeaheadPopup - result rendering', function () { expect(liElems.eq(2)).toHaveClass('active'); }); - it('should select an item on mouse click', function () { - + it('should select an item on mouse click', function() { scope.matches = ['foo', 'bar', 'baz']; scope.active = 1; $rootScope.select = angular.noop; diff --git a/src/typeahead/test/typeahead.spec.js b/src/typeahead/test/typeahead.spec.js index 259f8feb1e..92a75de3f4 100644 --- a/src/typeahead/test/typeahead.spec.js +++ b/src/typeahead/test/typeahead.spec.js @@ -1,5 +1,4 @@ -describe('typeahead tests', function () { - +describe('typeahead tests', function() { var $scope, $compile, $document, $timeout; var changeInputValueTo; @@ -7,17 +6,17 @@ describe('typeahead tests', function () { beforeEach(module('template/typeahead/typeahead-popup.html')); beforeEach(module('template/typeahead/typeahead-match.html')); beforeEach(module(function($compileProvider) { - $compileProvider.directive('formatter', function () { + $compileProvider.directive('formatter', function() { return { require: 'ngModel', link: function (scope, elm, attrs, ngModelCtrl) { - ngModelCtrl.$formatters.unshift(function (viewVal) { + ngModelCtrl.$formatters.unshift(function(viewVal) { return 'formatted' + viewVal; }); } }; }); - $compileProvider.directive('childDirective', function () { + $compileProvider.directive('childDirective', function() { return { restrict: 'A', require: '^parentDirective', @@ -25,7 +24,7 @@ describe('typeahead tests', function () { }; }); })); - beforeEach(inject(function (_$rootScope_, _$compile_, _$document_, _$timeout_, $sniffer) { + beforeEach(inject(function(_$rootScope_, _$compile_, _$document_, _$timeout_, $sniffer) { $scope = _$rootScope_; $scope.source = ['foo', 'bar', 'baz']; $scope.states = [ @@ -35,7 +34,7 @@ describe('typeahead tests', function () { $compile = _$compile_; $document = _$document_; $timeout = _$timeout_; - changeInputValueTo = function (element, value) { + changeInputValueTo = function(element, value) { var inputEl = findInput(element); inputEl.val(value); inputEl.trigger($sniffer.hasEvent('input') ? 'input' : 'change'); @@ -44,25 +43,25 @@ describe('typeahead tests', function () { })); //utility functions - var prepareInputEl = function (inputTpl) { + var prepareInputEl = function(inputTpl) { var el = $compile(angular.element(inputTpl))($scope); $scope.$digest(); return el; }; - var findInput = function (element) { + var findInput = function(element) { return element.find('input'); }; - var findDropDown = function (element) { + var findDropDown = function(element) { return element.find('ul.dropdown-menu'); }; - var findMatches = function (element) { + var findMatches = function(element) { return findDropDown(element).find('li'); }; - var triggerKeyDown = function (element, keyCode) { + var triggerKeyDown = function(element, keyCode) { var inputEl = findInput(element); var e = $.Event('keydown'); e.which = keyCode; @@ -117,20 +116,18 @@ describe('typeahead tests', function () { }); }); - afterEach(function () { + afterEach(function() { findDropDown($document.find('body')).remove(); }); //coarse grained, "integration" tests - describe('initial state and model changes', function () { - - it('should be closed by default', function () { + describe('initial state and model changes', function() { + it('should be closed by default', function() { var element = prepareInputEl('
'); expect(element).toBeClosed(); }); - it('should correctly render initial state if the "as" keyword is used', function () { - + it('should correctly render initial state if the "as" keyword is used', function() { $scope.result = $scope.states[0]; var element = prepareInputEl(''); @@ -139,8 +136,7 @@ describe('typeahead tests', function () { expect(inputEl.val()).toEqual('Alaska'); }); - it('should default to bound model for initial rendering if there is not enough info to render label', function () { - + it('should default to bound model for initial rendering if there is not enough info to render label', function() { $scope.result = $scope.states[0].code; var element = prepareInputEl(''); @@ -149,7 +145,7 @@ describe('typeahead tests', function () { expect(inputEl.val()).toEqual('AL'); }); - it('should not get open on model change', function () { + it('should not get open on model change', function() { var element = prepareInputEl(''); $scope.$apply(function () { $scope.result = 'foo'; @@ -158,9 +154,8 @@ describe('typeahead tests', function () { }); }); - describe('basic functionality', function () { - - it('should open and close typeahead based on matches', function () { + describe('basic functionality', function() { + it('should open and close typeahead based on matches', function() { var element = prepareInputEl(''); var inputEl = findInput(element); var ownsId = inputEl.attr('aria-owns'); @@ -182,7 +177,7 @@ describe('typeahead tests', function () { expect(inputEl.attr('aria-activedescendant')).toBeUndefined(); }); - it('should allow expressions over multiple lines', function () { + it('should allow expressions over multiple lines', function() { var element = prepareInputEl(''); changeInputValueTo(element, 'ba'); @@ -192,14 +187,14 @@ describe('typeahead tests', function () { expect(element).toBeClosed(); }); - it('should not open typeahead if input value smaller than a defined threshold', function () { + it('should not open typeahead if input value smaller than a defined threshold', function() { var element = prepareInputEl(''); changeInputValueTo(element, 'b'); expect(element).toBeClosed(); }); - it('should support custom model selecting function', function () { - $scope.updaterFn = function (selectedItem) { + it('should support custom model selecting function', function() { + $scope.updaterFn = function(selectedItem) { return 'prefix' + selectedItem; }; var element = prepareInputEl(''); @@ -208,8 +203,8 @@ describe('typeahead tests', function () { expect($scope.result).toEqual('prefixfoo'); }); - it('should support custom label rendering function', function () { - $scope.formatterFn = function (sourceItem) { + it('should support custom label rendering function', function() { + $scope.formatterFn = function(sourceItem) { return 'prefix' + sourceItem; }; @@ -219,20 +214,19 @@ describe('typeahead tests', function () { expect(matchHighlight).toEqual('prefixfoo'); }); - it('should by default bind view value to model even if not part of matches', function () { + it('should by default bind view value to model even if not part of matches', function() { var element = prepareInputEl(''); changeInputValueTo(element, 'not in matches'); expect($scope.result).toEqual('not in matches'); }); - it('should support the editable property to limit model bindings to matches only', function () { + it('should support the editable property to limit model bindings to matches only', function() { var element = prepareInputEl(''); changeInputValueTo(element, 'not in matches'); expect($scope.result).toEqual(undefined); }); - it('should set validation errors for non-editable inputs', function () { - + it('should set validation errors for non-editable inputs', function() { var element = prepareInputEl( '