Angularjs 测试select标签、angular js和jasmine
我有一个选择框,当我改变另一个选择时它会过滤。正在尝试编写e2e测试 这是我的标记:Angularjs 测试select标签、angular js和jasmine,angularjs,jasmine,Angularjs,Jasmine,我有一个选择框,当我改变另一个选择时它会过滤。正在尝试编写e2e测试 这是我的标记: <select id="inputPipe" ng-model="selectedPipe" ng-options="p.title_en for p in pipes"></select> <select id="inputSize" ng-model="selectedSize" ng-options="s.nominalsize for s in sizesFromPipe
<select id="inputPipe" ng-model="selectedPipe" ng-options="p.title_en for p in pipes"></select>
<select id="inputSize" ng-model="selectedSize" ng-options="s.nominalsize for s in sizesFromPipes"></select>
那我就不知道该怎么继续了
这是一个伪代码:
expect(<select>('sizesFromPipes[5].nominalsize').toBe('DN50')
expect(('sizesFromPipes[5].nominalsize').toBe('DN50'))
最后一个怎么写对呢?也许它能帮助您:
select('selectedPipe').option('Steel');
expect(input('selectedPipe').val()).toBe('0'); // key
select('selectedSize').option('DN50');
expect(input('selectedPipe').val()).toBe('1'); // key
我的应用程序中有如下内容:
HTML:
这是量角器,不是纯粹的因果报应!
select('selectedPipe').option('Steel');
expect(input('selectedPipe').val()).toBe('0'); // key
select('selectedSize').option('DN50');
expect(input('selectedPipe').val()).toBe('1'); // key
<select ng-model="filter.country" ng-options="c.name for c in countries"></select>
<select ng-model="filter.region" ng-options="r.name for r in filter.country.regions"></select>
it('should filter on country and region select choose', function() {
select('filter.country').option('Germany');
// 0 because this is key of selected option
expect(input('filter.country').val()).toBe('0');
select('filter.region').option('Hesse');
// 1 because this is key of selected option
expect(input('filter.region').val()).toBe('1');
});