plugin.open();
});
+ it('traps focus if trapFocus option is true', function(done) {
+ $html = $(template).appendTo('body');
+ plugin = new Foundation.OffCanvas($html.find('[data-off-canvas]'), {trapFocus: true});
+
+ let spy = sinon.spy(Foundation.Keyboard, 'trapFocus');
+
+ $html.one(Foundation.transitionend($html), function() {
+ sinon.assert.called(spy);
+ Foundation.Keyboard.trapFocus.restore();
+ done();
+ });
+
+ plugin.open();
+ });
+
it('fires opened.zf.offcanvas event', function(done) {
$html = $(template).appendTo('body');
$html = $(template).appendTo('body');
plugin = new Foundation.OffCanvas($html.find('[data-off-canvas]'), {});
-
-
$html.one(Foundation.transitionend($html), function() {
$html.one('closed.zf.offcanvas', function() {
done();
// Open it first
plugin.open();
});
+
+ it('releases focus if trapFocus option is true', function() {
+ $html = $(template).appendTo('body');
+ plugin = new Foundation.OffCanvas($html.find('[data-off-canvas]'), {trapFocus: true});
+
+ $html.one(Foundation.transitionend($html), function() {
+ let spy = sinon.spy(Foundation.Keyboard, 'releaseFocus');
+
+ plugin.close();
+
+ sinon.assert.called(spy);
+ Foundation.Keyboard.releaseFocus.restore();
+ });
+
+ // Open it first...
+ plugin.open();
+ });
});
describe('toggle()', function() {