Skip to content

Commit

Permalink
Merge pull request #1793 from anotherchrisberry/omg-regions
Browse files Browse the repository at this point in the history
fix initial selection on regionSelectField
  • Loading branch information
anotherchrisberry committed Dec 11, 2015
2 parents a746c72 + 9ac5ac0 commit 3836bec
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
ng-model="component[field]"
ng-change="onChange()"
required>
<option ng-repeat="region in regions" value="{{region.name}}" ng-selected="component[field] === region">{{region.name}}</option>
<option ng-repeat="region in regions" value="{{region.name}}" ng-selected="component[field] === region.name">{{region.name}}</option>
</select>
<p ng-if="readOnly" class="form-control-static">{{component[field]}}</p>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,21 @@ describe('Directives: regionSelectField', function () {
expect(option.value).toBe(expected[idx]);
});
});

it('selects correct initial value', function () {
var scope = this.scope;

scope.regions = [{name: 'us-east-1'}, {name: 'us-west-1'}];

scope.model = { regionField: 'us-west-1', accountField: 'a'};

var html = '<region-select-field regions="regions" component="model" field="regionField" account="model.accountField" provider="\'aws\'" label-columns="2"></region-select-field>';

var elem = this.compile(html)(scope);
scope.$digest();

var options = elem.find('option');
expect(options[1].selected).toBe(true);

});
});

0 comments on commit 3836bec

Please sign in to comment.