【问题标题】:Ember 2.8: Test that a ember-bootstrap modal is open on page loadEmber 2.8:测试 ember-bootstrap 模式是否在页面加载时打开
【发布时间】:2016-10-10 20:05:47
【问题描述】:

由于我没有使用纯 Bootstrap 模态,我一直无法弄清楚如何对在页面加载时打开的模态进行单元测试。这是有问题的模态:

{{#bs-modal class="startModal" footer=false open=openModal title="Start Game" closedAction="closeModal" backdropClose=false closeButton=false}}
  //modal content
{{/bs-modal}}

我尝试添加一个 startModal 类,希望通过我的单元测试中的 find 以某种方式捕获它

游戏测试.js

test('Initial modal shows up', function(assert) {
  visit('/');
  andThen(function () {
    assert.equal(find('.startModal').length, 1);
  });
});

这个测试通过了,但它并不是我真正想要的。我需要断言模态实际上是显示的,而不仅仅是存在的。

【问题讨论】:

    标签: unit-testing ember.js ember-qunit ember-testing


    【解决方案1】:

    为什么不检查模式或 css 属性更改上附加的类:

    test('Initial modal shows up', function(assert) {
      visit('/');
      andThen(function () {
        assert.equal(find('.startModal').hasClass('opened'), true);
        // or 
        // assert.equal(find('.startModal').css('display'), 'block');
      });
    });
    

    【讨论】:

      猜你喜欢
      • 2021-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多