Jquery 如何使用Konacha测试fullCalendar是否已初始化

Jquery 如何使用Konacha测试fullCalendar是否已初始化,jquery,fullcalendar,konacha,Jquery,Fullcalendar,Konacha,我正在Rails应用程序中使用它,并希望测试我正在使用它的页面 在名为fullcal_init的文件中,我有以下(工作)代码 它生成 我正在尝试使用以下代码对其进行测试: #test_helper //= require jquery //= require chai-jquery //= require "application" ... #my_tests.js //= require "test_helper" var $ = jQuery "use strict"; des

我正在Rails应用程序中使用它,并希望测试我正在使用它的页面

在名为
fullcal_init
的文件中,我有以下(工作)代码

它生成

我正在尝试使用以下代码对其进行测试:

#test_helper

//= require jquery
//= require chai-jquery
//= require "application"

...

#my_tests.js

//= require "test_helper"

var $ = jQuery

"use strict";

describe('fullcalendar_init', function() {

    it('renders the fullCalendar event stream', function() {
        ('#konacha').fullCalendar;
        assert.ok($('#konacha').should.have.class('fc'));
    });

});

但是,这不起作用-Konacha测试体没有任何附加类。关于使用Konacha的文档并不多(特别是在
backbone.js
上下文之外)-有人能告诉我如何测试
fullcalendar
是否正在初始化吗?

我通过使用随附的
done
回调来实现这一点。问题是
fullcalendar
需要一些时间来渲染,但我的测试立即启动,因此没有时间添加
fc
类。换句话说,我的代码是异步的,而我的测试不是。以下代码起作用:

it('renders fullCalendar plugin', function(done) {
    $('#konacha').fullCalendar();
    done();
    $('.fc').should.exist;
});
it('renders fullCalendar plugin', function(done) {
    $('#konacha').fullCalendar();
    done();
    $('.fc').should.exist;
});