【问题标题】:Testing a select tag, angular js and jasmine测试选择标签、角度 js 和 jasmine
【发布时间】:2013-11-22 03:12:40
【问题描述】:

我有这个选择框,当我更改另一个选择时会过滤。正在尝试编写 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 sizesFromPipes"></select>

所以当我更改第一个选择时,第二个会被过滤。

这是我的 e2e 测试

select('selectedPipe').option('Steel');

那我不知道怎么继续了。

这是一个伪代码:

expect(<select>('sizesFromPipes[5].nominalsize').toBe('DN50')

最后一个怎么写正确?

【问题讨论】:

    标签: angularjs jasmine


    【解决方案1】:

    也许对你有帮助:

    select('selectedPipe').option('Steel');
    expect(input('selectedPipe').val()).toBe('0'); // key
    
    select('selectedSize').option('DN50');
    expect(input('selectedPipe').val()).toBe('1'); // key
    

    我的应用中有这样的东西:

    HTML:

    <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>
    

    JavaScript:

    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'); 
    });
    

    【讨论】:

    • 它是量角器而不是纯粹的业力!
    猜你喜欢
    • 2020-12-07
    • 2016-06-03
    • 1970-01-01
    • 1970-01-01
    • 2015-03-23
    • 2013-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多