我怎么能要求mocha / chai在预期测试完成之前等待模态显示?
我正在包装bootstrap模式并发出我自己的事件。 show
工作正常,但我需要等待模式为shown
才能进行下一次测试。我根本无法让done()
工作。
describe("Modal", function() {
describe("wrapModalEvents", function() {
it("should wrap the show.bs.modal event", function() {
var m = new Modal();
m.wrapModalEvents();
var res = {e:1};
m.on('show', function(){
res.e = 555;
});
m.modal();
expect(res.e).to.equal(555);
});
it("should wrap the shown.bs.modal event", function() {
var m = new Modal();
m.wrapModalEvents();
var res = {e:1};
m.on('shown', function(){
res.e = 123;
});
// need to wait at least one second
expect(res.e).to.equal(123);
});
});
});