<NME> featherlight_test.js
<BEF> var expect = chai.expect;
var stubAjaxLoad = function(content) {
  var oldLoad = $.fn.load;
  $.fn.load = function(url, callback) {
    var $this = this;
    $.fn.load = oldLoad;
    window.setTimeout(function() {
      $this.html(content);
      callback(null, "success");
			expect($('img').length).to.equal(0);
			$bound.click();
			setTimeout(function() {
				expect($('.featherlight img').attr('src')).to.equal('fixtures/photo.jpeg');
				$('.featherlight').click();
			}, 500 );
			setTimeout(function() {
				expect($('img:visible')).to.have.length(0);
				done();
			}, 1000 );
		});
	var triggerKeyCode = function(keyCode) {
		$(window).trigger($.Event("keyup", { keyCode: keyCode }));
	};
	var triggerEscape = function(){
		triggerKeyCode(27);
	};

	$.fx.off = true;
	$.fn.toJSON = function() { return 'jQuery: ' + this.selector + ' (' + this.length + ')' };

	describe('Featherlight', function() {
		beforeEach(resetFixtures);

			it('opens a dialog box', function() {
				$.featherlight('<p class="testing">This is a test<p>');
				expect($('.featherlight p.testing').is(':visible')).to.be.ok;
			});

		});
					expect($('.featherlight img')).to.be.visible;
					expect($('.featherlight img')).to.have.attr('src').equal('fixtures/photo.jpeg');
					$('.featherlight').click();
				}, function() {
					expect($('img')).to.not.be.visible;
				}
			]);
		});

		it ('works on items with data-featherlight by default', function(done) {
			$('body').append('<div id="auto-bound-2" data-featherlight="fixtures/photo.jpeg">Dynamic</div>')
			expect($('img')).to.not.be.visible;
			$('#auto-bound-2').click();
			patiently(done, [
				function() {
					expect($('.featherlight img')).to.be.visible;
					expect($('.featherlight img')).to.have.attr('src').equal('fixtures/photo.jpeg');
					$('.featherlight').click();
				}, function() {
					expect($('img')).to.not.be.visible;
				}
			]);
		});

		it ('does not move content that was already placed in the featherlight by content-filters', function() {
			$.featherlight.contentFilters.advancedExample = {
				process: function() {
					return $('<p>Hello</p>').appendTo(this.$instance);
				}
			};
			$.featherlight({advancedExample: 'dummy'});
			expect($('.featherlight > p').length).to.equal(1);
		});

		describe('jQuery#featherlight', function() {

			it('is chainable', function() {
				// Not a bad test to run on collection methods.
				var $all_links = $('a')
				expect($all_links.featherlight()).to.equal($all_links);
			});

			it("won't open a dialog if the event is already prevented", function(){
				$('#plain-photo-link').on('click', function(event) { event.preventDefault(); })
				.featherlight().click();
				expect($.featherlight.current()).to.be.null;
			});
		});

		describe('jQuery.featherlight', function() {

			it('opens a dialog box', function() {
				$.featherlight('<p class="testing">This is a test<p>');
				expect($('.featherlight p.testing')).to.be.visible;
			});

		});

		describe('jQuery.featherlight#open', function() {
			it('returns a promise', function(done) {
				var fl = new $.featherlight('<p class="testing">This is a test<p>');
				expect($.featherlight.current()).to.be.null;
				var evt = $.Event('dummy');
				evt.preventDefault();
				expect(fl.open(evt).state()).to.equal('rejected');
				expect($.featherlight.current()).to.be.null;
				fl.open().then(function(){ done(); });
			});
		});

		describe('jQuery.featherlight.current', function() {
			it('returns null if no dialogbox is currently opened', function() {
				expect($.featherlight.current()).to.be.null;
				/* even if opened and then closed */
				$.featherlight('<p class="testing">This is a test<p>');
				$('.featherlight').click();
				expect($.featherlight.current()).to.be.null;
				/* even if savagely removed */
				$.featherlight('<p class="testing">This is a test<p>');
				$('.featherlight').remove();
				expect($.featherlight.current()).to.be.null;
			});

			it('returns the featherlight object of the last currently opened dialog', function() {
				var first = $.featherlight('<p>First<p>');
				expect($.featherlight.current()).to.equal(first);
				var second = $.featherlight('<p>Inner<p>', {namespace: 'different_namespace'});
				expect($.featherlight.current()).to.equal(second);
				$('.different_namespace').click();
				expect($.featherlight.current()).to.equal(first);
			});

		});

		describe('jQuery.featherlight.opened', function() {
			it('returns [] ]if no dialogbox is currently opened', function() {
				expect($.featherlight.opened()).to.eql([]);
				/* even if opened and then closed */
				$.featherlight('<p class="testing">This is a test<p>');
				$('.featherlight').click();
				expect($.featherlight.opened()).to.eql([]);
				/* even if savagely removed */
				$.featherlight('<p class="testing">This is a test<p>');
				$('.featherlight').remove();
				expect($.featherlight.opened()).to.eql([]);
			});

			it('returns the featherlight objects of the currently opened dialog', function() {
				var first = $.featherlight('<p>First<p>');
				expect($.featherlight.opened()).to.eql([first]);
				var second = $.featherlight('<p>Inner<p>', {namespace: 'different_namespace'});
				expect($.featherlight.opened()).to.eql([first, second]);
				$('.different_namespace').click();
				expect($.featherlight.opened()).to.eql([first]);
			});
		});

		describe('jQuery.featherlight.close', function() {
			it('closes the currently opened window, if any', function() {
				$.featherlight('<p class="testing">This is a test<p>');
				$.featherlight.close();
				expect($.featherlight.current()).to.be.null;
				$.featherlight.close(); /* should not create error */
			});
		});

		describe('jQuery.featherlight.close', function() {
			it('returns a promise', function(done) {
				$.featherlight('<p class="testing">This is a test<p>');
				$.featherlight.close().then(function(){ done() });
			});
		});

		describe('image content filter', function() {
			it('stores the natural width & height', function(done) {
				$('#plain-photo-link').featherlight({
					afterOpen: function() {
						expect(this.$content.naturalWidth).to.equal(200);
						done();
					}
				}).click();
			});
		});

		describe('configuration', function() {
			it('can be set using data-featherlight-*', function() {
				$('#data-attr-test a').featherlight().click();
				expect($.featherlight.current()).to.have.properties({
					variant: 'test',
					closeOnEsc: false,
					closeSpeed: 42,
				});
				expect($.featherlight.current().$instance.find('b')).to.have.text('Added in callback');
			});

			it('can be set using data-featherlight-* on filtered element too', function() {
				$('#data-attr-filter-test a:first').click();
				expect($.featherlight.current()).to.have.property('variant').equal('wrapper');
				$('#data-attr-filter-test a:last').click();
				expect($.featherlight.current()).to.have.property('variant').equal('inner');
				$('<a data-featherlight-variant="dynamic" href=".some-content">z</a>')
					.appendTo($('#data-attr-filter-test')).click()
				expect($.featherlight.current()).to.have.property('variant').equal('dynamic');
			});

			it('can specify to close or not on escape key', function() {
				var first = $.featherlight('<p/>'),
					second = $.featherlight('<p/>'),
					third = $.featherlight('<p/>', {closeOnEsc: false}),
					last = $.featherlight('<p/>', {closeOnEsc: true});
				expect($.featherlight._globalHandlerInstalled).to.be.true;
				triggerEscape();
				expect($.featherlight.current()).to.equal(third);
				triggerEscape();
				expect($('.featherlight')).with.length(3);
				$('.featherlight:last').click();
				expect($.featherlight.current()).to.equal(second);
				triggerEscape();
				expect($.featherlight.current()).to.equal(first);
				expect($.featherlight._globalHandlerInstalled).to.be.true;
				$.featherlight.current().close();
				expect($.featherlight._globalHandlerInstalled).to.be.false;
			});

			it('can specify to a close icon', function() {
				var fl = $.featherlight('<p/>', {closeIcon: '<div class="test">X</div>'});
				expect($.featherlight.current()).to.equal(fl);
				$('.test').click();
				expect($.featherlight.current()).to.be.null;
			});

			it('can specify a key handler', function() {
				var lastKeyCode;
				$.featherlight('<p/>', {
					onKeyUp: function(event) {
						lastKeyCode = event.keyCode;
					}
				});
				triggerKeyCode(25);
				expect(lastKeyCode).to.equal(25);
				triggerKeyCode(27);
				expect(lastKeyCode).to./* still be */equal(25); /* since event is handled by FL */
				expect($.featherlight.current()).to.be.null;
			});

			it('can specify a resize handler', function() {
				var resizes = [],
				  open = function() {
						$.featherlight('<p/>', {
							onResize: function(event) { resizes.push(this.id); }
						});
					}
				open();
				open();
				$(window).trigger('resize');
				open();
				$.featherlight.current().close();
				$.featherlight.current().close();
				$(window).trigger('resize');
				resizes = $.map(resizes, function(id) { return id - $.featherlight.current().id });
				expect(resizes).to.eql([0, 1, 1, 0, 2, 0]);
			});

			it('can specify a filter for events', function() {
				$("#filter-test .group").featherlight({filter: '.yes', type: 'text'})
					.append('<span class="yes"  href="filter Appended">Photo</span>');
				$("#filter-test span").each(function(){ $(this).click(); });
				expect($('.featherlight')).with.length(2);
				expect($('.featherlight:first .featherlight-content')).to.contain('filter Yes');
				expect($('.featherlight:last  .featherlight-content')).to.contain('filter Appended');
			});

			it('can specify explicit content', function() {
				$.featherlight({text: 'A <div> & "quoted text"'});
				expect($('.featherlight')).to.contain('A <div> & "quoted text"');
			});

			it('can specify ajax content', function(done) {
				$.featherlight({ajax: 'featherlight.html .some-content'});
				patiently(done, function() {
					expect($('.featherlight')).to.contain('Hello');
				});
			});

			it('can recover from an ajax load error, like a 404', function(done) {
				var modal = new $.featherlight({ajax: 'bad-url-not-found.html'});
				var p = modal.open();
				var callbackCalled = false;
				p.fail(function() {
					callbackCalled = true;
				})
				patiently(done, function() {
					expect(callbackCalled).to.be.true;
				});
			});

			it('ajax content can be text only', function(done) {
				stubAjaxLoad('Hello <b>world</b>');
				$.featherlight({ajax: 'stubbed'});
				patiently(done, function() {
					expect($('.featherlight')).to.contain('Hello');
				});
			});

			it('can specify an alternate close button selector', function() {
				var fl = $.featherlight('<div>Test<div class="close-me">close</div></div>', {otherClose: '.close-me'});
				expect($.featherlight.current()).to.equal(fl);
				$('.close-me').click();
				expect($.featherlight.current()).to.be.null;
			});

			it('can specify an alternate root selector', function() {
				$.featherlight('<div>Test<div class="close-me">close</div></div>', {root: '#fixtures'});
				expect($('#fixtures').children().last()).to.have.class('featherlight');
			});

			it('can specify callbacks to track the progress of the dialog', function() {
				var callbacks = ['beforeOpen', 'beforeContent', 'afterContent', 'afterOpen', 'beforeClose', 'afterClose'],
					lastCallback = undefined,
					options = {};
				$.each(callbacks, function(i, cb){
					options[cb] = function() {
						expect(lastCallback).to.equal(callbacks[i-1]);
						lastCallback = cb;
					}
				});
				$.featherlight($('<p>Hello</p>'), options);
				expect(lastCallback).to.equal('afterOpen');
				$.featherlight.current().close();
				expect(lastCallback).to.equal('afterClose');
			});

			it('can be interrupted via beforeOpen', function() {
				$.featherlight({text: "Hello", beforeOpen: function() { return false; }});
				expect($.featherlight.current()).to.be.null;
				// Tricky case:
				$.featherlight.defaults.beforeOpen = function() { return false; }
				$('#auto-bound').click();
				expect($.featherlight.current()).to.be.null;
				$.featherlight.defaults.beforeOpen = $.noop;
			});

			it('provides event to beforeClose when close via closebox', function() {
				$.featherlight({text: "Hello", beforeClose: function(evt) {
					expect(evt).to.be.an('object');
				}});
				$('.featherlight-close').click();
			});

			it('provides event to beforeClose & al when closed via escape', function() {
				$.featherlight({text: "Hello", beforeClose: function(evt) {
					expect(evt).to.be.an('object');
				}});
				triggerEscape();
			});

			it('passes event to beforeClose & al when closed via global function', function() {
				$.featherlight({text: "Hello", beforeClose: function(evt) {
					expect(evt).to.eql(42);
				}});
				$.featherlight.close(42);
			});

			it('can specify a loading text', function(done) {
				stubAjaxLoad('<b>Hi</b>');
				$.featherlight({ajax: 'stubbed', loading: "Spinner!"});
				expect($('.featherlight')).to.contain('Spinner!');
				expect($('.featherlight')).to.have.class('featherlight-loading');
				patiently(done, function() {
					expect($('.featherlight')).to.contain('Hi');
					expect($('.featherlight')).not.to.contain('Spinner!');
					expect($('.featherlight')).not.to.have.class('featherlight-loading');
				});
			});

			it('can specify a different namespace', function() {
				$('#namespace-test a').featherlight({namespace: 'custom-namespace'}).click();
				expect($.featherlight.current().$instance.find('b')).to.have.text('Namespace ok');
			});

			it('can specify to persist the content', function() {
				var $elem = $('<div class="keepme"/>').appendTo('body');
				expect($('.keepme')).with.length(1).to.have.text('');
				var fl = $.featherlight({
					jquery: $elem,
					persist: true,
					afterContent: function() { this.$content.append('<i>1</i>'); },
					afterOpen: function() { this.$content.append('<b>2</b>'); }
				});
				expect($('.keepme')).with.length(1).to.have.text('12');
				$.featherlight.close();
				fl.open();
				expect($('.keepme')).with.length(1).to.have.text('1212');
				$.featherlight.close();
			});

			var persistTest = function(setting, lastValue) {
				$('<div class="keepme">Foo</div>').appendTo('body');
				$('<div class="other">Bar</div>').appendTo('body');
				var $buttons = $('<a href=".keepme"/><a href=".other"/>').appendTo('body');
				$buttons.featherlight({ persist: setting });
				$buttons.first().click();
				$.featherlight.close();
				$buttons.first().click();
				expect($('.featherlight-inner')).to.have.text('Foo');
				$.featherlight.close();
				$buttons.last().click();
				expect($('.featherlight-inner')).to.have.text(lastValue);
			};

			it('can specify to persist the content individually', function() {
				persistTest(true, 'Bar');
			});

			it('can specify to persist the share the content as a group', function() {
				persistTest('shared', 'Foo');
			});

		});

		describe('error handling', function() {
			it('is quite basic', function(done) {
				$.featherlight('does_not_exist.jpg');
				patiently(done, function() {
					expect($('.featherlight-image')).to.have.attr('src').equal('does_not_exist.jpg');
					expect($('.featherlight')).not.to.have.class('featherlight-loading');
				});
			});
		});

		describe('iframe content filter', function() {
			it('generates an iframe with the right attributes and css', function(done) {
				$('<a data-featherlight-iframe="#test-iframe" data-featherlight-iframe-allowfullscreen="true" '+
					'data-featherlight-iframe-width="323" data-featherlight-iframe-min-height="212">').featherlight().click();
				expect($('.featherlight iframe')).to.have.attr('src').equal('#test-iframe');
				expect($('.featherlight iframe')).to.have.css('width').equal('323px');
				expect($('.featherlight iframe')).to.have.css('min-height').equal('212px');
				expect($('.featherlight iframe')).to.have.attr('allowfullscreen').equal('true');
				expect($('.featherlight iframe')).not.to.have.attr('min-height');
				patiently(done, function() {
					expect($('.featherlight')).to.have.attr('class').equal('featherlight featherlight-iframe');
				});
			});

			it('allows "about:blank"', function() {
				$('<a data-featherlight-iframe="about:blank">').featherlight().click();
				expect($('.featherlight iframe')).to.have.attr('src').equal('about:blank');
			});
		});

		describe('accessibility', function() {
			it('has a focusable close button', function() {
				$.featherlight({text: 'Hello'});
				close = $('.featherlight-close-icon')
				close.focus();
				expect($('.featherlight-close-icon').attr('tabindex')).to.be.undefined;
				expect($(document.activeElement)).to.have.class('featherlight-close-icon');
			});

			it('removes focus and then resets it', function() {
				$('.for-focus').focus();
				$.featherlight({text: 'Hello'});
				expect($('.for-focus')).to.have.attr('tabindex', '-1');
				expect($(document.activeElement)).not.to.have.class('for-focus');
				$.featherlight.close();
				expect($(document.activeElement)).to.have.class('for-focus');
				expect($('.for-focus').attr('tabindex')).to.be.undefined;
			});

			it('resets tabindex properly', function() {
				$('.for-focus').attr('tabindex', 42);
				$.featherlight({text: 'Hello'});
				$.featherlight.close();
				expect($('.for-focus')).to.have.attr('tabindex').equal('42');
			});

			it('focussed on "autofocus" content, if any', function() {
				$.featherlight({html: '<input><input autofocus class="ok">'});
				expect($(document.activeElement)).to.have.class('ok');
				$.featherlight.close();
			});

			it('sets the "with-featherlight" class correctly on html', function() {
				expect($('html')).not.to.have.class('with-featherlight');
				$.featherlight({html: 'hello'});
				expect($('html')).to.have.class('with-featherlight');
				$.featherlight({html: 'hello'});
				$.featherlight.close();
				$.featherlight.close();
				expect($('html')).not.to.have.class('with-featherlight');
			});

			it('works correctly with filters [#235]', function() {
				var ok = false;
				var fn = function(evt) {
					ok = !evt.isDefaultPrevented();
				};
				$(document).on('click', fn);
				$('#bug-235 .unrelated').click();
				$(document).off('click', fn);
				expect(ok).to.eql(true);
			});

		});
	});
}(jQuery));

<MSG> Use chai-jquery

<DFF> @@ -10,11 +10,12 @@ var expect = chai.expect;
 			expect($('img').length).to.equal(0);
 			$bound.click();
 			setTimeout(function() {
-				expect($('.featherlight img').attr('src')).to.equal('fixtures/photo.jpeg');
+				expect($('.featherlight img')).to.be.visible;
+				expect($('.featherlight img')).to.have.attr('src').equal('fixtures/photo.jpeg');
 				$('.featherlight').click();
 			}, 500 );
 			setTimeout(function() {
-				expect($('img:visible')).to.have.length(0);
+				expect($('img')).to.not.be.visible;
 				done();
 			}, 1000 );
 		});
@@ -33,7 +34,7 @@ var expect = chai.expect;
 
 			it('opens a dialog box', function() {
 				$.featherlight('<p class="testing">This is a test<p>');
-				expect($('.featherlight p.testing').is(':visible')).to.be.ok;
+				expect($('.featherlight p.testing')).to.be.visible;
 			});
 
 		});

{'commit': 'diff --git a/bower.json b/bower.json\nindex 0a2a406..4d10a1a 100644\n--- a/bower.json\n+++ b/bower.json\n@@ -15,6 +15,7 @@\n     "jquery": "~1.7.0",\n     "requirejs": "~2.1.10",\n     "chai": "~1.9.1",\n+    "chai-jquery": "*",\n     "mocha": "~1.18.2"\n   },\n   "keywords": [\ndiff --git a/test/featherlight.html b/test/featherlight.html\nindex 4be7109..38555a4 100644\n--- a/test/featherlight.html\n+++ b/test/featherlight.html\n@@ -10,6 +10,7 @@\n   <div id="mocha"></div>\n   <script src="../bower_components/jquery/jquery.js"></script>\n   <script src="../bower_components/chai/chai.js"></script>\n+  <script src="../bower_components/chai-jquery/chai-jquery.js"></script>\n   <script src="../bower_components/mocha/mocha.js"></script>\n   <script>mocha.setup(\'bdd\')</script>\n   <script src="../src/featherlight.js"></script>\ndiff --git a/test/featherlight_test.js b/test/featherlight_test.js\nindex ae63f0c..6407b85 100644\n--- a/test/featherlight_test.js\n+++ b/test/featherlight_test.js\n@@ -10,11 +10,12 @@ var expect = chai.expect;\n \t\t\texpect($(\'img\').length).to.equal(0);\n \t\t\t$bound.click();\n \t\t\tsetTimeout(function() {\n-\t\t\t\texpect($(\'.featherlight img\').attr(\'src\')).to.equal(\'fixtures/photo.jpeg\');\n+\t\t\t\texpect($(\'.featherlight img\')).to.be.visible;\n+\t\t\t\texpect($(\'.featherlight img\')).to.have.attr(\'src\').equal(\'fixtures/photo.jpeg\');\n \t\t\t\t$(\'.featherlight\').click();\n \t\t\t}, 500 );\n \t\t\tsetTimeout(function() {\n-\t\t\t\texpect($(\'img:visible\')).to.have.length(0);\n+\t\t\t\texpect($(\'img\')).to.not.be.visible;\n \t\t\t\tdone();\n \t\t\t}, 1000 );\n \t\t});\n@@ -33,7 +34,7 @@ var expect = chai.expect;\n \n \t\t\tit(\'opens a dialog box\', function() {\n \t\t\t\t$.featherlight(\'<p class="testing">This is a test<p>\');\n-\t\t\t\texpect($(\'.featherlight p.testing\').is(\':visible\')).to.be.ok;\n+\t\t\t\texpect($(\'.featherlight p.testing\')).to.be.visible;\n \t\t\t});\n \n \t\t});\n', 'commit_subject': 'Use chai-jquery', 'repo_name': 'noelboss/featherlight', 'committer': {'name': 'Marc-Andre Lafortune', 'email': '64b2b6d12bfe4baae7dad3d018f8cbf6b0e7a044@marc-andre.ca', 'time_sec': '1396046985', 'tz_offset': '-240', 'date': {'seconds': '1396046985'}}, 'commit_tree': 'fdefa5263c391cb87c8528859bc967ae9aa33e8a', 'commit_message': 'Use chai-jquery\n', 'language_name': 'HTML', 'license': 'mit', 'hunks': '@@ -10,11 +10,12 @@ var expect = chai.expect;\n \t\t\texpect($(\'img\').length).to.equal(0);\n \t\t\t$bound.click();\n \t\t\tsetTimeout(function() {\n-\t\t\t\texpect($(\'.featherlight img\').attr(\'src\')).to.equal(\'fixtures/photo.jpeg\');\n+\t\t\t\texpect($(\'.featherlight img\')).to.be.visible;\n+\t\t\t\texpect($(\'.featherlight img\')).to.have.attr(\'src\').equal(\'fixtures/photo.jpeg\');\n \t\t\t\t$(\'.featherlight\').click();\n \t\t\t}, 500 );\n \t\t\tsetTimeout(function() {\n-\t\t\t\texpect($(\'img:visible\')).to.have.length(0);\n+\t\t\t\texpect($(\'img\')).to.not.be.visible;\n \t\t\t\tdone();\n \t\t\t}, 1000 );\n \t\t});\n@@ -33,7 +34,7 @@ var expect = chai.expect;\n \n \t\t\tit(\'opens a dialog box\', function() {\n \t\t\t\t$.featherlight(\'<p class="testing">This is a test<p>\');\n-\t\t\t\texpect($(\'.featherlight p.testing\').is(\':visible\')).to.be.ok;\n+\t\t\t\texpect($(\'.featherlight p.testing\')).to.be.visible;\n \t\t\t});\n \n \t\t});\n', 'addition_count': 4, 'deletion_count': 3, 'src_file': 'a/test/featherlight_test.js', 'tgt_file': 'b/test/featherlight_test.js', 'file_extension': '.js', 'before_file': 'var expect = chai.expect;\nvar stubAjaxLoad = function(content) {\n  var oldLoad = $.fn.load;\n  $.fn.load = function(url, callback) {\n    var $this = this;\n    $.fn.load = oldLoad;\n    window.setTimeout(function() {\n      $this.html(content);\n      callback(null, "success");\n\t\t\texpect($(\'img\').length).to.equal(0);\n\t\t\t$bound.click();\n\t\t\tsetTimeout(function() {\n\t\t\t\texpect($(\'.featherlight img\').attr(\'src\')).to.equal(\'fixtures/photo.jpeg\');\n\t\t\t\t$(\'.featherlight\').click();\n\t\t\t}, 500 );\n\t\t\tsetTimeout(function() {\n\t\t\t\texpect($(\'img:visible\')).to.have.length(0);\n\t\t\t\tdone();\n\t\t\t}, 1000 );\n\t\t});\n\tvar triggerKeyCode = function(keyCode) {\n\t\t$(window).trigger($.Event("keyup", { keyCode: keyCode }));\n\t};\n\tvar triggerEscape = function(){\n\t\ttriggerKeyCode(27);\n\t};\n\n\t$.fx.off = true;\n\t$.fn.toJSON = function() { return \'jQuery: \' + this.selector + \' (\' + this.length + \')\' };\n\n\tdescribe(\'Featherlight\', function() {\n\t\tbeforeEach(resetFixtures);\n\n\t\t\tit(\'opens a dialog box\', function() {\n\t\t\t\t$.featherlight(\'<p class="testing">This is a test<p>\');\n\t\t\t\texpect($(\'.featherlight p.testing\').is(\':visible\')).to.be.ok;\n\t\t\t});\n\n\t\t});\n\t\t\t\t\texpect($(\'.featherlight img\')).to.be.visible;\n\t\t\t\t\texpect($(\'.featherlight img\')).to.have.attr(\'src\').equal(\'fixtures/photo.jpeg\');\n\t\t\t\t\t$(\'.featherlight\').click();\n\t\t\t\t}, function() {\n\t\t\t\t\texpect($(\'img\')).to.not.be.visible;\n\t\t\t\t}\n\t\t\t]);\n\t\t});\n\n\t\tit (\'works on items with data-featherlight by default\', function(done) {\n\t\t\t$(\'body\').append(\'<div id="auto-bound-2" data-featherlight="fixtures/photo.jpeg">Dynamic</div>\')\n\t\t\texpect($(\'img\')).to.not.be.visible;\n\t\t\t$(\'#auto-bound-2\').click();\n\t\t\tpatiently(done, [\n\t\t\t\tfunction() {\n\t\t\t\t\texpect($(\'.featherlight img\')).to.be.visible;\n\t\t\t\t\texpect($(\'.featherlight img\')).to.have.attr(\'src\').equal(\'fixtures/photo.jpeg\');\n\t\t\t\t\t$(\'.featherlight\').click();\n\t\t\t\t}, function() {\n\t\t\t\t\texpect($(\'img\')).to.not.be.visible;\n\t\t\t\t}\n\t\t\t]);\n\t\t});\n\n\t\tit (\'does not move content that was already placed in the featherlight by content-filters\', function() {\n\t\t\t$.featherlight.contentFilters.advancedExample = {\n\t\t\t\tprocess: function() {\n\t\t\t\t\treturn $(\'<p>Hello</p>\').appendTo(this.$instance);\n\t\t\t\t}\n\t\t\t};\n\t\t\t$.featherlight({advancedExample: \'dummy\'});\n\t\t\texpect($(\'.featherlight > p\').length).to.equal(1);\n\t\t});\n\n\t\tdescribe(\'jQuery#featherlight\', function() {\n\n\t\t\tit(\'is chainable\', function() {\n\t\t\t\t// Not a bad test to run on collection methods.\n\t\t\t\tvar $all_links = $(\'a\')\n\t\t\t\texpect($all_links.featherlight()).to.equal($all_links);\n\t\t\t});\n\n\t\t\tit("won\'t open a dialog if the event is already prevented", function(){\n\t\t\t\t$(\'#plain-photo-link\').on(\'click\', function(event) { event.preventDefault(); })\n\t\t\t\t.featherlight().click();\n\t\t\t\texpect($.featherlight.current()).to.be.null;\n\t\t\t});\n\t\t});\n\n\t\tdescribe(\'jQuery.featherlight\', function() {\n\n\t\t\tit(\'opens a dialog box\', function() {\n\t\t\t\t$.featherlight(\'<p class="testing">This is a test<p>\');\n\t\t\t\texpect($(\'.featherlight p.testing\')).to.be.visible;\n\t\t\t});\n\n\t\t});\n\n\t\tdescribe(\'jQuery.featherlight#open\', function() {\n\t\t\tit(\'returns a promise\', function(done) {\n\t\t\t\tvar fl = new $.featherlight(\'<p class="testing">This is a test<p>\');\n\t\t\t\texpect($.featherlight.current()).to.be.null;\n\t\t\t\tvar evt = $.Event(\'dummy\');\n\t\t\t\tevt.preventDefault();\n\t\t\t\texpect(fl.open(evt).state()).to.equal(\'rejected\');\n\t\t\t\texpect($.featherlight.current()).to.be.null;\n\t\t\t\tfl.open().then(function(){ done(); });\n\t\t\t});\n\t\t});\n\n\t\tdescribe(\'jQuery.featherlight.current\', function() {\n\t\t\tit(\'returns null if no dialogbox is currently opened\', function() {\n\t\t\t\texpect($.featherlight.current()).to.be.null;\n\t\t\t\t/* even if opened and then closed */\n\t\t\t\t$.featherlight(\'<p class="testing">This is a test<p>\');\n\t\t\t\t$(\'.featherlight\').click();\n\t\t\t\texpect($.featherlight.current()).to.be.null;\n\t\t\t\t/* even if savagely removed */\n\t\t\t\t$.featherlight(\'<p class="testing">This is a test<p>\');\n\t\t\t\t$(\'.featherlight\').remove();\n\t\t\t\texpect($.featherlight.current()).to.be.null;\n\t\t\t});\n\n\t\t\tit(\'returns the featherlight object of the last currently opened dialog\', function() {\n\t\t\t\tvar first = $.featherlight(\'<p>First<p>\');\n\t\t\t\texpect($.featherlight.current()).to.equal(first);\n\t\t\t\tvar second = $.featherlight(\'<p>Inner<p>\', {namespace: \'different_namespace\'});\n\t\t\t\texpect($.featherlight.current()).to.equal(second);\n\t\t\t\t$(\'.different_namespace\').click();\n\t\t\t\texpect($.featherlight.current()).to.equal(first);\n\t\t\t});\n\n\t\t});\n\n\t\tdescribe(\'jQuery.featherlight.opened\', function() {\n\t\t\tit(\'returns [] ]if no dialogbox is currently opened\', function() {\n\t\t\t\texpect($.featherlight.opened()).to.eql([]);\n\t\t\t\t/* even if opened and then closed */\n\t\t\t\t$.featherlight(\'<p class="testing">This is a test<p>\');\n\t\t\t\t$(\'.featherlight\').click();\n\t\t\t\texpect($.featherlight.opened()).to.eql([]);\n\t\t\t\t/* even if savagely removed */\n\t\t\t\t$.featherlight(\'<p class="testing">This is a test<p>\');\n\t\t\t\t$(\'.featherlight\').remove();\n\t\t\t\texpect($.featherlight.opened()).to.eql([]);\n\t\t\t});\n\n\t\t\tit(\'returns the featherlight objects of the currently opened dialog\', function() {\n\t\t\t\tvar first = $.featherlight(\'<p>First<p>\');\n\t\t\t\texpect($.featherlight.opened()).to.eql([first]);\n\t\t\t\tvar second = $.featherlight(\'<p>Inner<p>\', {namespace: \'different_namespace\'});\n\t\t\t\texpect($.featherlight.opened()).to.eql([first, second]);\n\t\t\t\t$(\'.different_namespace\').click();\n\t\t\t\texpect($.featherlight.opened()).to.eql([first]);\n\t\t\t});\n\t\t});\n\n\t\tdescribe(\'jQuery.featherlight.close\', function() {\n\t\t\tit(\'closes the currently opened window, if any\', function() {\n\t\t\t\t$.featherlight(\'<p class="testing">This is a test<p>\');\n\t\t\t\t$.featherlight.close();\n\t\t\t\texpect($.featherlight.current()).to.be.null;\n\t\t\t\t$.featherlight.close(); /* should not create error */\n\t\t\t});\n\t\t});\n\n\t\tdescribe(\'jQuery.featherlight.close\', function() {\n\t\t\tit(\'returns a promise\', function(done) {\n\t\t\t\t$.featherlight(\'<p class="testing">This is a test<p>\');\n\t\t\t\t$.featherlight.close().then(function(){ done() });\n\t\t\t});\n\t\t});\n\n\t\tdescribe(\'image content filter\', function() {\n\t\t\tit(\'stores the natural width & height\', function(done) {\n\t\t\t\t$(\'#plain-photo-link\').featherlight({\n\t\t\t\t\tafterOpen: function() {\n\t\t\t\t\t\texpect(this.$content.naturalWidth).to.equal(200);\n\t\t\t\t\t\tdone();\n\t\t\t\t\t}\n\t\t\t\t}).click();\n\t\t\t});\n\t\t});\n\n\t\tdescribe(\'configuration\', function() {\n\t\t\tit(\'can be set using data-featherlight-*\', function() {\n\t\t\t\t$(\'#data-attr-test a\').featherlight().click();\n\t\t\t\texpect($.featherlight.current()).to.have.properties({\n\t\t\t\t\tvariant: \'test\',\n\t\t\t\t\tcloseOnEsc: false,\n\t\t\t\t\tcloseSpeed: 42,\n\t\t\t\t});\n\t\t\t\texpect($.featherlight.current().$instance.find(\'b\')).to.have.text(\'Added in callback\');\n\t\t\t});\n\n\t\t\tit(\'can be set using data-featherlight-* on filtered element too\', function() {\n\t\t\t\t$(\'#data-attr-filter-test a:first\').click();\n\t\t\t\texpect($.featherlight.current()).to.have.property(\'variant\').equal(\'wrapper\');\n\t\t\t\t$(\'#data-attr-filter-test a:last\').click();\n\t\t\t\texpect($.featherlight.current()).to.have.property(\'variant\').equal(\'inner\');\n\t\t\t\t$(\'<a data-featherlight-variant="dynamic" href=".some-content">z</a>\')\n\t\t\t\t\t.appendTo($(\'#data-attr-filter-test\')).click()\n\t\t\t\texpect($.featherlight.current()).to.have.property(\'variant\').equal(\'dynamic\');\n\t\t\t});\n\n\t\t\tit(\'can specify to close or not on escape key\', function() {\n\t\t\t\tvar first = $.featherlight(\'<p/>\'),\n\t\t\t\t\tsecond = $.featherlight(\'<p/>\'),\n\t\t\t\t\tthird = $.featherlight(\'<p/>\', {closeOnEsc: false}),\n\t\t\t\t\tlast = $.featherlight(\'<p/>\', {closeOnEsc: true});\n\t\t\t\texpect($.featherlight._globalHandlerInstalled).to.be.true;\n\t\t\t\ttriggerEscape();\n\t\t\t\texpect($.featherlight.current()).to.equal(third);\n\t\t\t\ttriggerEscape();\n\t\t\t\texpect($(\'.featherlight\')).with.length(3);\n\t\t\t\t$(\'.featherlight:last\').click();\n\t\t\t\texpect($.featherlight.current()).to.equal(second);\n\t\t\t\ttriggerEscape();\n\t\t\t\texpect($.featherlight.current()).to.equal(first);\n\t\t\t\texpect($.featherlight._globalHandlerInstalled).to.be.true;\n\t\t\t\t$.featherlight.current().close();\n\t\t\t\texpect($.featherlight._globalHandlerInstalled).to.be.false;\n\t\t\t});\n\n\t\t\tit(\'can specify to a close icon\', function() {\n\t\t\t\tvar fl = $.featherlight(\'<p/>\', {closeIcon: \'<div class="test">X</div>\'});\n\t\t\t\texpect($.featherlight.current()).to.equal(fl);\n\t\t\t\t$(\'.test\').click();\n\t\t\t\texpect($.featherlight.current()).to.be.null;\n\t\t\t});\n\n\t\t\tit(\'can specify a key handler\', function() {\n\t\t\t\tvar lastKeyCode;\n\t\t\t\t$.featherlight(\'<p/>\', {\n\t\t\t\t\tonKeyUp: function(event) {\n\t\t\t\t\t\tlastKeyCode = event.keyCode;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\ttriggerKeyCode(25);\n\t\t\t\texpect(lastKeyCode).to.equal(25);\n\t\t\t\ttriggerKeyCode(27);\n\t\t\t\texpect(lastKeyCode).to./* still be */equal(25); /* since event is handled by FL */\n\t\t\t\texpect($.featherlight.current()).to.be.null;\n\t\t\t});\n\n\t\t\tit(\'can specify a resize handler\', function() {\n\t\t\t\tvar resizes = [],\n\t\t\t\t  open = function() {\n\t\t\t\t\t\t$.featherlight(\'<p/>\', {\n\t\t\t\t\t\t\tonResize: function(event) { resizes.push(this.id); }\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\topen();\n\t\t\t\topen();\n\t\t\t\t$(window).trigger(\'resize\');\n\t\t\t\topen();\n\t\t\t\t$.featherlight.current().close();\n\t\t\t\t$.featherlight.current().close();\n\t\t\t\t$(window).trigger(\'resize\');\n\t\t\t\tresizes = $.map(resizes, function(id) { return id - $.featherlight.current().id });\n\t\t\t\texpect(resizes).to.eql([0, 1, 1, 0, 2, 0]);\n\t\t\t});\n\n\t\t\tit(\'can specify a filter for events\', function() {\n\t\t\t\t$("#filter-test .group").featherlight({filter: \'.yes\', type: \'text\'})\n\t\t\t\t\t.append(\'<span class="yes"  href="filter Appended">Photo</span>\');\n\t\t\t\t$("#filter-test span").each(function(){ $(this).click(); });\n\t\t\t\texpect($(\'.featherlight\')).with.length(2);\n\t\t\t\texpect($(\'.featherlight:first .featherlight-content\')).to.contain(\'filter Yes\');\n\t\t\t\texpect($(\'.featherlight:last  .featherlight-content\')).to.contain(\'filter Appended\');\n\t\t\t});\n\n\t\t\tit(\'can specify explicit content\', function() {\n\t\t\t\t$.featherlight({text: \'A <div> & "quoted text"\'});\n\t\t\t\texpect($(\'.featherlight\')).to.contain(\'A <div> & "quoted text"\');\n\t\t\t});\n\n\t\t\tit(\'can specify ajax content\', function(done) {\n\t\t\t\t$.featherlight({ajax: \'featherlight.html .some-content\'});\n\t\t\t\tpatiently(done, function() {\n\t\t\t\t\texpect($(\'.featherlight\')).to.contain(\'Hello\');\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tit(\'can recover from an ajax load error, like a 404\', function(done) {\n\t\t\t\tvar modal = new $.featherlight({ajax: \'bad-url-not-found.html\'});\n\t\t\t\tvar p = modal.open();\n\t\t\t\tvar callbackCalled = false;\n\t\t\t\tp.fail(function() {\n\t\t\t\t\tcallbackCalled = true;\n\t\t\t\t})\n\t\t\t\tpatiently(done, function() {\n\t\t\t\t\texpect(callbackCalled).to.be.true;\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tit(\'ajax content can be text only\', function(done) {\n\t\t\t\tstubAjaxLoad(\'Hello <b>world</b>\');\n\t\t\t\t$.featherlight({ajax: \'stubbed\'});\n\t\t\t\tpatiently(done, function() {\n\t\t\t\t\texpect($(\'.featherlight\')).to.contain(\'Hello\');\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tit(\'can specify an alternate close button selector\', function() {\n\t\t\t\tvar fl = $.featherlight(\'<div>Test<div class="close-me">close</div></div>\', {otherClose: \'.close-me\'});\n\t\t\t\texpect($.featherlight.current()).to.equal(fl);\n\t\t\t\t$(\'.close-me\').click();\n\t\t\t\texpect($.featherlight.current()).to.be.null;\n\t\t\t});\n\n\t\t\tit(\'can specify an alternate root selector\', function() {\n\t\t\t\t$.featherlight(\'<div>Test<div class="close-me">close</div></div>\', {root: \'#fixtures\'});\n\t\t\t\texpect($(\'#fixtures\').children().last()).to.have.class(\'featherlight\');\n\t\t\t});\n\n\t\t\tit(\'can specify callbacks to track the progress of the dialog\', function() {\n\t\t\t\tvar callbacks = [\'beforeOpen\', \'beforeContent\', \'afterContent\', \'afterOpen\', \'beforeClose\', \'afterClose\'],\n\t\t\t\t\tlastCallback = undefined,\n\t\t\t\t\toptions = {};\n\t\t\t\t$.each(callbacks, function(i, cb){\n\t\t\t\t\toptions[cb] = function() {\n\t\t\t\t\t\texpect(lastCallback).to.equal(callbacks[i-1]);\n\t\t\t\t\t\tlastCallback = cb;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\t$.featherlight($(\'<p>Hello</p>\'), options);\n\t\t\t\texpect(lastCallback).to.equal(\'afterOpen\');\n\t\t\t\t$.featherlight.current().close();\n\t\t\t\texpect(lastCallback).to.equal(\'afterClose\');\n\t\t\t});\n\n\t\t\tit(\'can be interrupted via beforeOpen\', function() {\n\t\t\t\t$.featherlight({text: "Hello", beforeOpen: function() { return false; }});\n\t\t\t\texpect($.featherlight.current()).to.be.null;\n\t\t\t\t// Tricky case:\n\t\t\t\t$.featherlight.defaults.beforeOpen = function() { return false; }\n\t\t\t\t$(\'#auto-bound\').click();\n\t\t\t\texpect($.featherlight.current()).to.be.null;\n\t\t\t\t$.featherlight.defaults.beforeOpen = $.noop;\n\t\t\t});\n\n\t\t\tit(\'provides event to beforeClose when close via closebox\', function() {\n\t\t\t\t$.featherlight({text: "Hello", beforeClose: function(evt) {\n\t\t\t\t\texpect(evt).to.be.an(\'object\');\n\t\t\t\t}});\n\t\t\t\t$(\'.featherlight-close\').click();\n\t\t\t});\n\n\t\t\tit(\'provides event to beforeClose & al when closed via escape\', function() {\n\t\t\t\t$.featherlight({text: "Hello", beforeClose: function(evt) {\n\t\t\t\t\texpect(evt).to.be.an(\'object\');\n\t\t\t\t}});\n\t\t\t\ttriggerEscape();\n\t\t\t});\n\n\t\t\tit(\'passes event to beforeClose & al when closed via global function\', function() {\n\t\t\t\t$.featherlight({text: "Hello", beforeClose: function(evt) {\n\t\t\t\t\texpect(evt).to.eql(42);\n\t\t\t\t}});\n\t\t\t\t$.featherlight.close(42);\n\t\t\t});\n\n\t\t\tit(\'can specify a loading text\', function(done) {\n\t\t\t\tstubAjaxLoad(\'<b>Hi</b>\');\n\t\t\t\t$.featherlight({ajax: \'stubbed\', loading: "Spinner!"});\n\t\t\t\texpect($(\'.featherlight\')).to.contain(\'Spinner!\');\n\t\t\t\texpect($(\'.featherlight\')).to.have.class(\'featherlight-loading\');\n\t\t\t\tpatiently(done, function() {\n\t\t\t\t\texpect($(\'.featherlight\')).to.contain(\'Hi\');\n\t\t\t\t\texpect($(\'.featherlight\')).not.to.contain(\'Spinner!\');\n\t\t\t\t\texpect($(\'.featherlight\')).not.to.have.class(\'featherlight-loading\');\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tit(\'can specify a different namespace\', function() {\n\t\t\t\t$(\'#namespace-test a\').featherlight({namespace: \'custom-namespace\'}).click();\n\t\t\t\texpect($.featherlight.current().$instance.find(\'b\')).to.have.text(\'Namespace ok\');\n\t\t\t});\n\n\t\t\tit(\'can specify to persist the content\', function() {\n\t\t\t\tvar $elem = $(\'<div class="keepme"/>\').appendTo(\'body\');\n\t\t\t\texpect($(\'.keepme\')).with.length(1).to.have.text(\'\');\n\t\t\t\tvar fl = $.featherlight({\n\t\t\t\t\tjquery: $elem,\n\t\t\t\t\tpersist: true,\n\t\t\t\t\tafterContent: function() { this.$content.append(\'<i>1</i>\'); },\n\t\t\t\t\tafterOpen: function() { this.$content.append(\'<b>2</b>\'); }\n\t\t\t\t});\n\t\t\t\texpect($(\'.keepme\')).with.length(1).to.have.text(\'12\');\n\t\t\t\t$.featherlight.close();\n\t\t\t\tfl.open();\n\t\t\t\texpect($(\'.keepme\')).with.length(1).to.have.text(\'1212\');\n\t\t\t\t$.featherlight.close();\n\t\t\t});\n\n\t\t\tvar persistTest = function(setting, lastValue) {\n\t\t\t\t$(\'<div class="keepme">Foo</div>\').appendTo(\'body\');\n\t\t\t\t$(\'<div class="other">Bar</div>\').appendTo(\'body\');\n\t\t\t\tvar $buttons = $(\'<a href=".keepme"/><a href=".other"/>\').appendTo(\'body\');\n\t\t\t\t$buttons.featherlight({ persist: setting });\n\t\t\t\t$buttons.first().click();\n\t\t\t\t$.featherlight.close();\n\t\t\t\t$buttons.first().click();\n\t\t\t\texpect($(\'.featherlight-inner\')).to.have.text(\'Foo\');\n\t\t\t\t$.featherlight.close();\n\t\t\t\t$buttons.last().click();\n\t\t\t\texpect($(\'.featherlight-inner\')).to.have.text(lastValue);\n\t\t\t};\n\n\t\t\tit(\'can specify to persist the content individually\', function() {\n\t\t\t\tpersistTest(true, \'Bar\');\n\t\t\t});\n\n\t\t\tit(\'can specify to persist the share the content as a group\', function() {\n\t\t\t\tpersistTest(\'shared\', \'Foo\');\n\t\t\t});\n\n\t\t});\n\n\t\tdescribe(\'error handling\', function() {\n\t\t\tit(\'is quite basic\', function(done) {\n\t\t\t\t$.featherlight(\'does_not_exist.jpg\');\n\t\t\t\tpatiently(done, function() {\n\t\t\t\t\texpect($(\'.featherlight-image\')).to.have.attr(\'src\').equal(\'does_not_exist.jpg\');\n\t\t\t\t\texpect($(\'.featherlight\')).not.to.have.class(\'featherlight-loading\');\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\n\t\tdescribe(\'iframe content filter\', function() {\n\t\t\tit(\'generates an iframe with the right attributes and css\', function(done) {\n\t\t\t\t$(\'<a data-featherlight-iframe="#test-iframe" data-featherlight-iframe-allowfullscreen="true" \'+\n\t\t\t\t\t\'data-featherlight-iframe-width="323" data-featherlight-iframe-min-height="212">\').featherlight().click();\n\t\t\t\texpect($(\'.featherlight iframe\')).to.have.attr(\'src\').equal(\'#test-iframe\');\n\t\t\t\texpect($(\'.featherlight iframe\')).to.have.css(\'width\').equal(\'323px\');\n\t\t\t\texpect($(\'.featherlight iframe\')).to.have.css(\'min-height\').equal(\'212px\');\n\t\t\t\texpect($(\'.featherlight iframe\')).to.have.attr(\'allowfullscreen\').equal(\'true\');\n\t\t\t\texpect($(\'.featherlight iframe\')).not.to.have.attr(\'min-height\');\n\t\t\t\tpatiently(done, function() {\n\t\t\t\t\texpect($(\'.featherlight\')).to.have.attr(\'class\').equal(\'featherlight featherlight-iframe\');\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tit(\'allows "about:blank"\', function() {\n\t\t\t\t$(\'<a data-featherlight-iframe="about:blank">\').featherlight().click();\n\t\t\t\texpect($(\'.featherlight iframe\')).to.have.attr(\'src\').equal(\'about:blank\');\n\t\t\t});\n\t\t});\n\n\t\tdescribe(\'accessibility\', function() {\n\t\t\tit(\'has a focusable close button\', function() {\n\t\t\t\t$.featherlight({text: \'Hello\'});\n\t\t\t\tclose = $(\'.featherlight-close-icon\')\n\t\t\t\tclose.focus();\n\t\t\t\texpect($(\'.featherlight-close-icon\').attr(\'tabindex\')).to.be.undefined;\n\t\t\t\texpect($(document.activeElement)).to.have.class(\'featherlight-close-icon\');\n\t\t\t});\n\n\t\t\tit(\'removes focus and then resets it\', function() {\n\t\t\t\t$(\'.for-focus\').focus();\n\t\t\t\t$.featherlight({text: \'Hello\'});\n\t\t\t\texpect($(\'.for-focus\')).to.have.attr(\'tabindex\', \'-1\');\n\t\t\t\texpect($(document.activeElement)).not.to.have.class(\'for-focus\');\n\t\t\t\t$.featherlight.close();\n\t\t\t\texpect($(document.activeElement)).to.have.class(\'for-focus\');\n\t\t\t\texpect($(\'.for-focus\').attr(\'tabindex\')).to.be.undefined;\n\t\t\t});\n\n\t\t\tit(\'resets tabindex properly\', function() {\n\t\t\t\t$(\'.for-focus\').attr(\'tabindex\', 42);\n\t\t\t\t$.featherlight({text: \'Hello\'});\n\t\t\t\t$.featherlight.close();\n\t\t\t\texpect($(\'.for-focus\')).to.have.attr(\'tabindex\').equal(\'42\');\n\t\t\t});\n\n\t\t\tit(\'focussed on "autofocus" content, if any\', function() {\n\t\t\t\t$.featherlight({html: \'<input><input autofocus class="ok">\'});\n\t\t\t\texpect($(document.activeElement)).to.have.class(\'ok\');\n\t\t\t\t$.featherlight.close();\n\t\t\t});\n\n\t\t\tit(\'sets the "with-featherlight" class correctly on html\', function() {\n\t\t\t\texpect($(\'html\')).not.to.have.class(\'with-featherlight\');\n\t\t\t\t$.featherlight({html: \'hello\'});\n\t\t\t\texpect($(\'html\')).to.have.class(\'with-featherlight\');\n\t\t\t\t$.featherlight({html: \'hello\'});\n\t\t\t\t$.featherlight.close();\n\t\t\t\t$.featherlight.close();\n\t\t\t\texpect($(\'html\')).not.to.have.class(\'with-featherlight\');\n\t\t\t});\n\n\t\t\tit(\'works correctly with filters [#235]\', function() {\n\t\t\t\tvar ok = false;\n\t\t\t\tvar fn = function(evt) {\n\t\t\t\t\tok = !evt.isDefaultPrevented();\n\t\t\t\t};\n\t\t\t\t$(document).on(\'click\', fn);\n\t\t\t\t$(\'#bug-235 .unrelated\').click();\n\t\t\t\t$(document).off(\'click\', fn);\n\t\t\t\texpect(ok).to.eql(true);\n\t\t\t});\n\n\t\t});\n\t});\n}(jQuery));\n', 'message': 'Use chai-jquery\n', 'author_name': 'Marc-Andre Lafortune', 'lang': 'js'}