diff --git a/src/components/chips/chips.spec.js b/src/components/chips/chips.spec.js index ffc85f9b5aa..978cb8319c3 100755 --- a/src/components/chips/chips.spec.js +++ b/src/components/chips/chips.spec.js @@ -362,6 +362,48 @@ describe('', function() { expect(element.find('md-chips-wrap').hasClass('md-focused')).toBe(false); })); + describe('placeholder', function() { + + it('should put placeholder text in the input element when chips exist but there is no secondary-placeholder text', inject(function() { + var template = + ''; + var element = buildChips(template); + var ctrl = element.controller('mdChips'); + var input = element.find('input')[0]; + + expect(scope.items.length).toBeGreaterThan(0); + expect(input.placeholder).toBe('placeholder text'); + })); + + it('should put placeholder text in the input element when there are no chips', inject(function() { + var ctrl, element, input, template; + + scope.items = []; + template = + ''; + element = buildChips(template); + ctrl = element.controller('mdChips'); + input = element.find('input')[0]; + + expect(scope.items.length).toBe(0); + expect(input.placeholder).toBe('placeholder text'); + })); + + it('should put secondary-placeholder text in the input element when there is at least one chip', inject(function() { + var template = + ''; + var element = buildChips(template); + var ctrl = element.controller('mdChips'); + var input = element.find('input')[0]; + + expect(scope.items.length).toBeGreaterThan(0); + expect(input.placeholder).toBe('secondary-placeholder text'); + })); + + }); + }); describe('custom inputs', function() { diff --git a/src/components/chips/js/chipsController.js b/src/components/chips/js/chipsController.js index 71ea1b2f29c..dfb7e877468 100755 --- a/src/components/chips/js/chipsController.js +++ b/src/components/chips/js/chipsController.js @@ -183,7 +183,7 @@ MdChipsCtrl.prototype.getPlaceholder = function() { // Allow `secondary-placeholder` to be blank. var useSecondary = (this.items.length && (this.secondaryPlaceholder == '' || this.secondaryPlaceholder)); - return useSecondary ? this.placeholder : this.secondaryPlaceholder; + return useSecondary ? this.secondaryPlaceholder : this.placeholder; }; /**