Skip to content

Commit

Permalink
test (mdChips: placeholder): add missing tests
Browse files Browse the repository at this point in the history
Add tests for the placeholder feature of `chipsController`(<mdChips>).
Previously there were no tests.

These tests demonstrate the failures reported as github issues angular#2770 and angular#4476.
  • Loading branch information
ericgundrum authored and ErinCoughlan committed Feb 9, 2016
1 parent ca6483a commit 18f47d3
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/components/chips/chips.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,48 @@ describe('<md-chips>', 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 =
'<md-chips ng-model="items" placeholder="placeholder text"></md-chips>';
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 =
'<md-chips ng-model="items" placeholder="placeholder text" ' +
'secondary-placeholder="secondary-placeholder text"></md-chips>';
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 =
'<md-chips ng-model="items" placeholder="placeholder text" ' +
'secondary-placeholder="secondary-placeholder text"></md-chips>';
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() {
Expand Down

0 comments on commit 18f47d3

Please sign in to comment.