From 18f47d31d13de5c7d961f8d6681218543a7fa2b0 Mon Sep 17 00:00:00 2001 From: Eric Gundrum Date: Mon, 4 Jan 2016 10:17:43 -0800 Subject: [PATCH] test (mdChips: placeholder): add missing tests Add tests for the placeholder feature of `chipsController`(). Previously there were no tests. These tests demonstrate the failures reported as github issues #2770 and #4476. --- src/components/chips/chips.spec.js | 42 ++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/components/chips/chips.spec.js b/src/components/chips/chips.spec.js index 93410aef06e..359b1fe00a2 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() {