测试选择的标签,角js和茉莉 [英] Testing a select tag, angular js and jasmine
本文介绍了测试选择的标签,角js和茉莉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这样的选择框,当我换另外一个选择哪些过滤器。试图写一个端到端的测试。
I have this select box which filters when I change another select. Trying to write a e2e test.
这是我的标记:
<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>
所以,当我改变第一选择第二个被过滤。
So when I change the first select the second gets filtered.
这是我的E2E测试
select('selectedPipe').option('Steel');
然后,我不知道如何继续。
Then I'm not sure how to continue.
这伪code:
expect(<select>('sizesFromPipes[5].nominalsize').toBe('DN50')
我如何写的最后一个正确的?
How do I write the last one correct?
推荐答案
也许它可以帮助您:
select('selectedPipe').option('Steel');
expect(input('selectedPipe').val()).toBe('0'); // key
select('selectedSize').option('DN50');
expect(input('selectedPipe').val()).toBe('1'); // key
我在我的应用程序是这样的:
I have in my app something like this:
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的:
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');
});
这篇关于测试选择的标签,角js和茉莉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文