<commit_before>/* eslint-env node, mocha */

const should = require("should");

const KeyCodes = {
	Enter: 13,
	Space: 32,
	End: 35,
	Home: 36,
	LeftArrow: 37,
	UpArrow: 38,
	RightArrow: 39,
	DownArrow: 40
};

describe("Tabs", function() {

	var $,
		document,
		Tabs;

	var tabsHTML = `
		<div class="tabs" data-nice-plugin="tabs">
			<nav>
				<ul class="tabs__list" role="tablist">
					<li class="tabs__tab" role="presentation">
						<button class="tabs__tab-btn" type="button" role="tab">
							Tab 1
						</button>
					</li>
					<li class="tabs__tab" role="presentation">
						<button  class="tabs__tab-btn"type="button" role="tab">
							Tab 2
						</abutton>
					</li>
					<li class="tabs__tab" role="presentation">
						<button class="tabs__tab-btn" type="button" role="tab">
							Tab 3
						</abutton>
					</li>
				</ul>
			</nav>
			<div class="tabs__content">
				<div lass="tabs__pane" role="tabpanel">
					<h2>First tab</h2>
					<p>This is the content for tab 1</p>
				</div>
				<div class="tabs__pane" role="tabpanel">
					<h2>Second tab</h2>
					<p>This is the content for tab 2</p>
				</div>
				<div class="tabs__pane" role="tabpanel">
					<h2>Third tab</h2>
					<p>This is the content for tab 3</p>
				</div>
			</div>
		</div>
	`;

	before(function () {
		document = global.document;
		$ = global.$;

		Tabs = require("../../src/javascripts/tabs.js").default;
	});

	describe("jQuery integration", function() {

		it("defined on jquery object", function() {
			$(document).tabs.should.be.ok();
		});

		it("have defaults", function() {
			$(document).tabs.should.have.property("defaults");
		});

		// TODO: Test no conflict

		it("return jquery collection containing the element", function() {
			var $el = $("<div/>");
			var $tabs = $el.tabs();

			$tabs.should.be.an.instanceOf($, "returns jquery collection");
			$tabs[0].should.equal($el[0], "collection contains element");
		});

		it("getter can be called", function() {
			var $el = $(tabsHTML).tabs();
			($el.tabs("getCurrentIndex")).should.equal(0);
		});

		it("method can be called", function() {
			var $el = $(tabsHTML).tabs();
			$el.tabs("activate", 1);
			($el.tabs("getCurrentIndex")).should.equal(1);
		});
	});

	describe("Initialization", function() {

		it("have defaults", function() {
			Tabs.should.have.property("defaults");
		});

		it("throw without element", function() {
			should.throws(() => new Tabs);
		});

	});

	describe("Tab selection", function() {

		it("first tab selected by default", function() {
			var $el = $(tabsHTML);<commit_msg>Update tabs tests to fix lint error and use globals and chai should<commit_after>/* eslint-env node, mocha, jquery */

const KeyCodes = {
	Enter: 13,
	Space: 32,
	End: 35,
	Home: 36,
	LeftArrow: 37,
	UpArrow: 38,
	RightArrow: 39,
	DownArrow: 40
};

describe("Tabs", function() {

	var Tabs;

	before(function () {
		Tabs = require("../../src/javascripts/tabs.js").default;
	});

	var tabsHTML = `
		<div class="tabs" data-nice-plugin="tabs">
			<nav>
				<ul class="tabs__list" role="tablist">
					<li class="tabs__tab" role="presentation">
						<button class="tabs__tab-btn" type="button" role="tab">
							Tab 1
						</button>
					</li>
					<li class="tabs__tab" role="presentation">
						<button  class="tabs__tab-btn"type="button" role="tab">
							Tab 2
						</abutton>
					</li>
					<li class="tabs__tab" role="presentation">
						<button class="tabs__tab-btn" type="button" role="tab">
							Tab 3
						</abutton>
					</li>
				</ul>
			</nav>
			<div class="tabs__content">
				<div lass="tabs__pane" role="tabpanel">
					<h2>First tab</h2>
					<p>This is the content for tab 1</p>
				</div>
				<div class="tabs__pane" role="tabpanel">
					<h2>Second tab</h2>
					<p>This is the content for tab 2</p>
				</div>
				<div class="tabs__pane" role="tabpanel">
					<h2>Third tab</h2>
					<p>This is the content for tab 3</p>
				</div>
			</div>
		</div>
	`;

	describe("jQuery integration", function() {

		it("defined on jquery object", function() {
			$(document).tabs.should.be.ok;
		});

		it("have defaults", function() {
			$(document).tabs.should.have.property("defaults");
		});

		// TODO: Test no conflict

		it("return jquery collection containing the element", function() {
			var $el = $("<div/>");
			var $tabs = $el.tabs();

			$tabs.should.be.an.instanceOf($, "returns jquery collection");
			$tabs[0].should.equal($el[0], "collection contains element");
		});

		it("getter can be called", function() {
			var $el = $(tabsHTML).tabs();
			($el.tabs("getCurrentIndex")).should.equal(0);
		});

		it("method can be called", function() {
			var $el = $(tabsHTML).tabs();
			$el.tabs("activate", 1);
			($el.tabs("getCurrentIndex")).should.equal(1);
		});
	});

	describe("Initialization", function() {

		it("have defaults", function() {
			Tabs.should.have.property("defaults");
		});

		it("throw error without element", function() {
			(() => {
				new Tabs;
			}).should.throw(Error);
		});

	});

	describe("Tab selection", function() {

		it("first tab selected by default", function() {
			var $el = $(tabsHTML);
{'fraction_non_alphanumeric': 0.1943146417445483, 'fraction_numerical': 0.012850467289719626, 'mean_word_length': 3.2279835390946503, 'pattern_counts': {'":': 0, '<': 81, '<?xml version=': 0, '>': 83, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6307659', 'n_tokens_mistral': 2215, 'n_tokens_neox': 1764, 'n_words': 416}