Testing select tag, angular js and jasmine

I have this select box that filters when I change another selection. Attempting to write an e2e test.

This is my markup:

<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 selection, the second is filtered.

This is my e2e test

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

      

Then I'm not sure how to proceed.

This is pseudocode:

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

      

How can I write the last correct one?

+1


source to share


1 answer


Maybe this will help you:

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

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

      

I have something like this in my application:

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

      

-2


source







All Articles