Simulate a ember-select2 selection in ember integration test

喜夏-厌秋 提交于 2020-01-05 08:32:25

问题


Has anyone been able to simulate a select2 selection of an option? So far I've tried this:

 test("Checking navigation", function () {
      expect(1);
      visit("/hub");
      click("#btnLogin");
      andThen(function () {
        click(".select2-container");
        andThen(function () {
        });
      });
    });

But I have not seen changes in the UI.


回答1:


We need to hit the anchor inside the container

  Ember.$(" .select2-container a").trigger({type:'mousedown', which:1});

If you want to select an item in the dropdown you can do:

Ember.$(".select2-results li div").trigger({type:'mouseup', which:1});



回答2:


After some playing around, I think this is what you're looking for:

find(".select2-container:first").trigger({type:'mousedown', which:1});


来源:https://stackoverflow.com/questions/28085394/simulate-a-ember-select2-selection-in-ember-integration-test

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!