From fe92a53e3159f23c26b2cb12ac4c62c4fbab474b Mon Sep 17 00:00:00 2001 From: Kushan Joshi <0o3ko0@gmail.com> Date: Wed, 15 Jun 2016 01:42:10 +0530 Subject: [PATCH] Add linting to `spec/lib` --- package.json | 3 +-- test/spec/lib/d3.combobox.js | 40 +++++++++++++++++----------------- test/spec/lib/d3.keybinding.js | 16 +++++++------- test/spec/lib/diff3.js | 2 +- test/spec/lib/locale.js | 14 +++++++----- 5 files changed, 38 insertions(+), 37 deletions(-) diff --git a/package.json b/package.json index b74751978..9fdf0d2ed 100644 --- a/package.json +++ b/package.json @@ -12,8 +12,7 @@ "start": "http-server .", "lint": "eslint js/id && npm run lint:spec:actions", "lint:modules": "eslint modules", - "lint:spec:actions": "eslint test/spec/actions", - "lint:spec:behavior": "eslint test/spec/behavior" + "lint:spec": "eslint test/spec/actions test/spec/behavior test/spec/core test/spec/geo test/spec/lib" }, "repository": { "type": "git", diff --git a/test/spec/lib/d3.combobox.js b/test/spec/lib/d3.combobox.js index dbf139954..9b4011643 100644 --- a/test/spec/lib/d3.combobox.js +++ b/test/spec/lib/d3.combobox.js @@ -1,4 +1,4 @@ -describe("d3.combobox", function() { +describe('d3.combobox', function() { var body, content, input, combobox; var data = [ @@ -69,19 +69,19 @@ describe("d3.combobox", function() { body.selectAll('.combobox').remove(); }); - it("adds the combobox-input class", function() { + it('adds the combobox-input class', function() { input.call(combobox); expect(input).to.be.classed('combobox-input'); }); - it("shows a menu of entries on focus", function() { + it('shows a menu of entries on focus', function() { input.call(combobox.data(data)); input.node().focus(); expect(body.selectAll('.combobox-option').size()).to.equal(3); expect(body.selectAll('.combobox-option').text()).to.equal('foo'); }); - it("filters entries to those matching the value", function() { + it('filters entries to those matching the value', function() { input.property('value', 'b').call(combobox.data(data)); input.node().focus(); expect(body.selectAll('.combobox-option').size()).to.equal(2); @@ -89,33 +89,33 @@ describe("d3.combobox", function() { expect(body.selectAll('.combobox-option')[0][1].text).to.equal('Baz'); }); - it("shows no menu on focus if it would contain only one item", function() { + it('shows no menu on focus if it would contain only one item', function() { input.property('value', 'f').call(combobox.data(data)); input.node().focus(); expect(body.selectAll('.combobox-option').size()).to.equal(0); }); - it("shows menu on focus if it would contain at least minItems items", function() { + it('shows menu on focus if it would contain at least minItems items', function() { combobox.minItems(1); input.property('value', 'f').call(combobox.data(data)); input.node().focus(); expect(body.selectAll('.combobox-option').size()).to.equal(1); }); - it("shows all entries when clicking on the caret", function() { + it('shows all entries when clicking on the caret', function() { input.property('value', 'foo').call(combobox.data(data)); happen.mousedown(body.selectAll('.combobox-caret').node()); expect(body.selectAll('.combobox-option').size()).to.equal(3); expect(body.selectAll('.combobox-option').text()).to.equal('foo'); }); - it("is initially shown with no selection", function() { + it('is initially shown with no selection', function() { input.call(combobox.data(data)); input.node().focus(); expect(body.selectAll('.combobox-option.selected').size()).to.equal(0); }); - it("selects the first option matching the input", function() { + it('selects the first option matching the input', function() { input.call(combobox.data(data)); input.node().focus(); simulateKeypress('b'); @@ -123,7 +123,7 @@ describe("d3.combobox", function() { expect(body.selectAll('.combobox-option.selected').text()).to.equal('bar'); }); - it("selects the completed portion of the value", function() { + it('selects the completed portion of the value', function() { input.call(combobox.data(data)); input.node().focus(); simulateKeypress('b'); @@ -132,7 +132,7 @@ describe("d3.combobox", function() { expect(input.property('selectionEnd')).to.equal(3); }); - it("does not preserve the case of the input portion of the value by default", function() { + it('does not preserve the case of the input portion of the value by default', function() { input.call(combobox.data(data)); input.node().focus(); simulateKeypress('B'); @@ -141,7 +141,7 @@ describe("d3.combobox", function() { expect(input.property('selectionEnd')).to.equal(3); }); - it("does preserve the case of the input portion of the value with caseSensitive option", function() { + it('does preserve the case of the input portion of the value with caseSensitive option', function() { combobox.caseSensitive(true); input.call(combobox.data(data)); input.node().focus(); @@ -151,14 +151,14 @@ describe("d3.combobox", function() { expect(input.property('selectionEnd')).to.equal(3); }); - it("does not select when value is empty", function() { + it('does not select when value is empty', function() { input.call(combobox.data(data)); input.node().focus(); happen.once(input.node(), {type: 'input'}); expect(body.selectAll('.combobox-option.selected').size()).to.equal(0); }); - it("does not select when value is not a prefix of any suggestion", function() { + it('does not select when value is not a prefix of any suggestion', function() { input.call(combobox.fetcher(function(_, cb) { cb(data); })); input.node().focus(); simulateKeypress('b'); @@ -166,7 +166,7 @@ describe("d3.combobox", function() { expect(body.selectAll('.combobox-option.selected').size()).to.equal(0); }); - it("does not select or autocomplete after ⌫", function() { + it('does not select or autocomplete after ⌫', function() { input.call(combobox.data(data)); input.node().focus(); simulateKeypress('b'); @@ -175,7 +175,7 @@ describe("d3.combobox", function() { expect(input.property('value')).to.equal('b'); }); - it("does not select or autocomplete after ⌦", function() { + it('does not select or autocomplete after ⌦', function() { input.call(combobox.data(data)); input.node().focus(); simulateKeypress('f'); @@ -187,7 +187,7 @@ describe("d3.combobox", function() { expect(input.property('value')).to.equal('b'); }); - it("selects and autocompletes the next/prev suggestion on ↓/↑", function() { + it('selects and autocompletes the next/prev suggestion on ↓/↑', function() { input.call(combobox.data(data)); input.node().focus(); @@ -207,7 +207,7 @@ describe("d3.combobox", function() { expect(input.property('value')).to.equal('foo'); }); - it("emits accepted event with selected datum on ⇥", function(done) { + it('emits accepted event with selected datum on ⇥', function(done) { combobox.on('accept', function(d) { expect(d).to.eql({title: 'bar', value: 'bar'}); done(); @@ -218,7 +218,7 @@ describe("d3.combobox", function() { simulateKeypress('⇥'); }); - it("emits accepted event with selected datum on ↩", function(done) { + it('emits accepted event with selected datum on ↩', function(done) { combobox.on('accept', function(d) { expect(d).to.eql({title: 'bar', value: 'bar'}); done(); @@ -229,7 +229,7 @@ describe("d3.combobox", function() { simulateKeypress('↩'); }); - it("hides on ↩", function() { + it('hides on ↩', function() { input.call(combobox.data(data)); input.node().focus(); simulateKeypress('↩'); diff --git a/test/spec/lib/d3.keybinding.js b/test/spec/lib/d3.keybinding.js index 1639cb459..cb96b946c 100644 --- a/test/spec/lib/d3.keybinding.js +++ b/test/spec/lib/d3.keybinding.js @@ -1,4 +1,4 @@ -describe("d3.keybinding", function() { +describe('d3.keybinding', function() { var keybinding, spy, input; beforeEach(function () { @@ -13,12 +13,12 @@ describe("d3.keybinding", function() { input.remove(); }); - describe("#on", function () { - it("returns self", function () { + describe('#on', function () { + it('returns self', function () { expect(keybinding.on('a', spy)).to.equal(keybinding); }); - it("adds a binding for the specified bare key", function () { + it('adds a binding for the specified bare key', function () { d3.select(document).call(keybinding.on('A', spy)); happen.keydown(document, {keyCode: 65, metaKey: true}); @@ -28,7 +28,7 @@ describe("d3.keybinding", function() { expect(spy).to.have.been.calledOnce; }); - it("adds a binding for the specified key combination", function () { + it('adds a binding for the specified key combination', function () { d3.select(document).call(keybinding.on('⌘+A', spy)); happen.keydown(document, {keyCode: 65}); @@ -38,21 +38,21 @@ describe("d3.keybinding", function() { expect(spy).to.have.been.calledOnce; }); - it("does not dispatch when focus is in input elements by default", function () { + it('does not dispatch when focus is in input elements by default', function () { d3.select(document).call(keybinding.on('A', spy)); happen.keydown(input.node(), {keyCode: 65}); expect(spy).not.to.have.been.called; }); - it("dispatches when focus is in input elements when the capture flag was passed", function () { + it('dispatches when focus is in input elements when the capture flag was passed', function () { d3.select(document).call(keybinding.on('A', spy, true)); happen.keydown(input.node(), {keyCode: 65}); expect(spy).to.have.been.calledOnce; }); - it("resets bindings when keybinding.off is called", function () { + it('resets bindings when keybinding.off is called', function () { d3.select(document).call(keybinding.on('A', spy)); happen.keydown(document, {keyCode: 65}); expect(spy).to.have.been.calledOnce; diff --git a/test/spec/lib/diff3.js b/test/spec/lib/diff3.js index 3cf741554..29c1db1cb 100644 --- a/test/spec/lib/diff3.js +++ b/test/spec/lib/diff3.js @@ -1,4 +1,4 @@ -describe("diff3", function() { +describe('diff3', function() { function split(s) { return s ? s.split(/ /) : []; } diff --git a/test/spec/lib/locale.js b/test/spec/lib/locale.js index 8b4c355fb..abf4b03c2 100644 --- a/test/spec/lib/locale.js +++ b/test/spec/lib/locale.js @@ -1,11 +1,13 @@ -describe("locale", function() { +/* global locale: true */ +/* eslint no-console: 0 */ +describe('locale', function() { var saved, error; beforeEach(function() { saved = locale; error = console.error; console.error = function () {}; - locale = { _current: 'en', en: {test: 'test', foo: 'bar'}, __: {}} + locale = { _current: 'en', en: {test: 'test', foo: 'bar'}, __: {}}; }); afterEach(function() { @@ -13,16 +15,16 @@ describe("locale", function() { console.error = error; }); - describe("t", function() { - it("defaults to locale._current", function() { + describe('t', function() { + it('defaults to locale._current', function() { expect(t('test')).to.equal('test'); }); - it("supports a default option", function() { + it('supports a default option', function() { expect(t('nonesuch', {default: 'default'})).to.equal('default'); }); - it("falls back to en", function() { + it('falls back to en', function() { locale._current = '__'; expect(t('test')).to.equal('test'); });