2

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

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

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

游戏-test.js

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

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

4

1 回答 1

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');
  });
});
于 2016-10-11T07:30:39.730 回答