From 485948688ffafd240f792b2f8e1810fae8fa09dc Mon Sep 17 00:00:00 2001 From: Martin Staffa Date: Thu, 13 Aug 2015 15:30:50 +0200 Subject: [PATCH] test(select): ensure that options with interpolated text are added / updated --- test/ng/directive/selectSpec.js | 66 ++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/test/ng/directive/selectSpec.js b/test/ng/directive/selectSpec.js index 3aca6176ec97..ec5d2bb3930f 100644 --- a/test/ng/directive/selectSpec.js +++ b/test/ng/directive/selectSpec.js @@ -964,22 +964,84 @@ describe('select', function() { describe('option', function() { - it('should populate value attribute on OPTION', function() { + it('should populate a missing value attribute with the option text', function() { compile(''); expect(element).toEqualSelect([unknownValue(undefined)], 'abc'); }); - it('should ignore value if already exists', function() { + + it('should ignore the option text if the value attribute exists', function() { compile(''); expect(element).toEqualSelect([unknownValue(undefined)], 'abc'); }); + it('should set value even if self closing HTML', function() { scope.x = 'hello'; compile(''); expect(element).toEqualSelect(['hello']); }); + + it('should add options with interpolated text', + inject(function($rootScope, $compile) { + var scope = $rootScope; + + scope.option1 = 'Option 1'; + scope.option2 = 'Option 2'; + + var element = $compile( + '' + + '' + + '' + + '')(scope); + + scope.$digest(); + expect(scope.selected).toBeUndefined(); + + //Change value of option2 + scope.option2 = 'Option 2 Changed'; + + scope.selected = 'Option 2 Changed'; + scope.$digest(); + expect(element.find('option').eq(1).prop('selected')).toBe(true); + expect(element.find('option').eq(1).text()).toBe('Option 2 Changed'); + + //Make sure the bindings are destroyed + dealoc(element); + }) + ); + it('should not blow up when option directive is found inside of a datalist', inject(function($compile, $rootScope) { var element = $compile('
' +