From a0fb2c227e66c7b034726943a96360829a5ad3b2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Scott=20Gonz=C3=A1lez?= Date: Wed, 18 Apr 2012 22:46:39 -0400 Subject: [PATCH] Tests: Lint. --- tests/unit/progressbar/progressbar_events.js | 2 +- tests/unit/resizable/resizable_methods.js | 2 +- tests/unit/selectable/selectable_methods.js | 16 ++--- tests/unit/selectable/selectable_options.js | 6 +- tests/unit/slider/slider_methods.js | 14 +++-- tests/unit/slider/slider_options.js | 10 +-- tests/unit/sortable/sortable_events.js | 64 ++++++++++---------- tests/unit/sortable/sortable_methods.js | 4 +- tests/unit/sortable/sortable_tickets.js | 4 +- 9 files changed, 63 insertions(+), 59 deletions(-) diff --git a/tests/unit/progressbar/progressbar_events.js b/tests/unit/progressbar/progressbar_events.js index 8d7b8868d..f3713171b 100644 --- a/tests/unit/progressbar/progressbar_events.js +++ b/tests/unit/progressbar/progressbar_events.js @@ -15,7 +15,7 @@ test("create", function() { change: function() { ok(false, 'create() has triggered change()'); } - }) + }); }); test("change", function() { diff --git a/tests/unit/resizable/resizable_methods.js b/tests/unit/resizable/resizable_methods.js index 03e91d440..2b4c4256c 100644 --- a/tests/unit/resizable/resizable_methods.js +++ b/tests/unit/resizable/resizable_methods.js @@ -20,7 +20,7 @@ test("init", function() { $('
').resizable().resizable("foo").remove(); ok(true, 'arbitrary method called after init'); - el = $('
').resizable() + el = $('
').resizable(); var foo = el.resizable("option", "foo"); el.remove(); ok(true, 'arbitrary option getter after init'); diff --git a/tests/unit/selectable/selectable_methods.js b/tests/unit/selectable/selectable_methods.js index 32dfe00ed..dbc88f269 100644 --- a/tests/unit/selectable/selectable_methods.js +++ b/tests/unit/selectable/selectable_methods.js @@ -20,7 +20,7 @@ test("init", function() { $("
").selectable().selectable("foo").remove(); ok(true, 'arbitrary method called after init'); - el = $("
").selectable() + el = $("
").selectable(); var foo = el.selectable("option", "foo"); el.remove(); ok(true, 'arbitrary option getter after init'); @@ -49,7 +49,8 @@ test("destroy", function() { test("enable", function() { expect(3); - var fired = false; + var expected, actual, + fired = false; el = $("#selectable1"); el.selectable({ @@ -63,14 +64,15 @@ test("enable", function() { equal(fired, true, "start fired"); el.selectable("destroy"); - var expected = $('
').selectable(), - actual = expected.selectable('enable'); + expected = $('
').selectable(); + actual = expected.selectable('enable'); equal(actual, expected, 'enable is chainable'); }); test("disable", function() { expect(3); - var fired = false; + var expected, actual, + fired = false; el = $("#selectable1"); el.selectable({ @@ -85,8 +87,8 @@ test("disable", function() { equal(fired, false, "start fired"); el.selectable("destroy"); - var expected = $('
').selectable(), - actual = expected.selectable('disable'); + expected = $('
').selectable(); + actual = expected.selectable('disable'); equal(actual, expected, 'disable is chainable'); }); diff --git a/tests/unit/selectable/selectable_options.js b/tests/unit/selectable/selectable_options.js index 2bc44e6e0..be9fdf5fe 100644 --- a/tests/unit/selectable/selectable_options.js +++ b/tests/unit/selectable/selectable_options.js @@ -8,7 +8,7 @@ module("selectable: options"); test("autoRefresh", function() { expect(3); el = $("#selectable1"); - var actual, sel = $("*", el), selected = function() { actual += 1 }; + var actual, sel = $("*", el), selected = function() { actual += 1; }; actual = 0; el = $("#selectable1").selectable({ autoRefresh: false, selected: selected }); @@ -33,12 +33,12 @@ test("autoRefresh", function() { test("filter", function() { expect(2); el = $("#selectable1"); - var actual, sel = $("*", el), selected = function() { actual += 1 }; + var actual, sel = $("*", el), selected = function() { actual += 1; }; actual = 0; el = $("#selectable1").selectable({ filter: '.special', selected: selected }); drag(1000, 1000); - ok(sel.length != 1, "this test assumes more than 1 selectee"); + ok(sel.length !== 1, "this test assumes more than 1 selectee"); equal(actual, 1); el.selectable("destroy"); }); diff --git a/tests/unit/slider/slider_methods.js b/tests/unit/slider/slider_methods.js index b46222002..79f80e868 100644 --- a/tests/unit/slider/slider_methods.js +++ b/tests/unit/slider/slider_methods.js @@ -17,8 +17,8 @@ test("init", function() { $('
').slider().remove(); ok(true, '.slider() called on disconnected DOMElement'); - var el = $('
').slider(); - var foo = el.slider("option", "foo"); + var el = $('
').slider(), + foo = el.slider("option", "foo"); el.remove(); ok(true, 'arbitrary option getter after init'); @@ -42,11 +42,12 @@ test("destroy", function() { }); test("enable", function() { - var expected = $('
').slider(), + var el, + expected = $('
').slider(), actual = expected.slider('enable'); equal(actual, expected, 'enable is chainable'); - var el = $('
').slider({ disabled: true }); + el = $('
').slider({ disabled: true }); ok(el.hasClass('ui-disabled'), 'slider has ui-disabled class before enable method call'); ok(el.hasClass('ui-slider-disabled'), 'slider has ui-slider-disabled class before enable method call'); el.slider('enable'); @@ -55,11 +56,12 @@ test("enable", function() { }); test("disable", function() { - var expected = $('
').slider(), + var el, + expected = $('
').slider(), actual = expected.slider('disable'); equal(actual, expected, 'disable is chainable'); - var el = $('
').slider({ disabled: false }); + el = $('
').slider({ disabled: false }); ok(!el.hasClass('ui-disabled'), 'slider does not have ui-disabled class before disabled method call'); ok(!el.hasClass('ui-slider-disabled'), 'slider does not have ui-slider-disabled class before disable method call'); el.slider('disable'); diff --git a/tests/unit/slider/slider_options.js b/tests/unit/slider/slider_options.js index 7d9899284..09067a3e9 100644 --- a/tests/unit/slider/slider_options.js +++ b/tests/unit/slider/slider_options.js @@ -23,8 +23,8 @@ test("max", function() { }; el.slider(options); - ok(el.slider("option", "value") == options.value, "value option is not contained by max"); - ok(el.slider("value") == options.max, "value method is contained by max"); + ok(el.slider("option", "value") === options.value, "value option is not contained by max"); + ok(el.slider("value") === options.max, "value method is contained by max"); el.slider('destroy'); }); @@ -41,8 +41,8 @@ test("min", function() { }; el.slider(options); - ok(el.slider("option", "value") == options.value, "value option is not contained by min"); - ok(el.slider("value") == options.min, "value method is contained by min"); + ok(el.slider("option", "value") === options.value, "value option is not contained by min"); + ok(el.slider("value") === options.min, "value method is contained by min"); el.slider('destroy'); }); @@ -73,7 +73,7 @@ test("orientation", function() { value: -1 }; - var percentVal = (options.value - options.min) / (options.max - options.min) * 100; + percentVal = (options.value - options.min) / (options.max - options.min) * 100; el.slider(options).slider("option", "orientation", "vertical"); ok(el.is('.ui-slider-vertical'), "vertical slider has class .ui-slider-vertical"); diff --git a/tests/unit/sortable/sortable_events.js b/tests/unit/sortable/sortable_events.js index cb4ff4ff3..6ed54e1b6 100644 --- a/tests/unit/sortable/sortable_events.js +++ b/tests/unit/sortable/sortable_events.js @@ -6,13 +6,13 @@ module("sortable: events"); test("start", function() { - + var hash; $("#sortable") .sortable({ start: function(e, ui) { hash = ui; } }) .find('li:eq(0)').simulate("drag", { dx: 0, dy: 10 }); - - ok(hash, 'start event triggered'); + + ok(hash, 'start event triggered'); ok(hash.helper, 'UI hash includes: helper'); ok(hash.placeholder, 'UI hash includes: placeholder'); ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position'); @@ -20,104 +20,104 @@ test("start", function() { ok(hash.item, 'UI hash includes: item'); ok(!hash.sender, 'UI hash does not include: sender'); - + }); test("sort", function() { - + var hash; $("#sortable") .sortable({ sort: function(e, ui) { hash = ui; } }) .find('li:eq(0)').simulate("drag", { dx: 0, dy: 10 }); - - ok(hash, 'sort event triggered'); + + ok(hash, 'sort event triggered'); ok(hash.helper, 'UI hash includes: helper'); ok(hash.placeholder, 'UI hash includes: placeholder'); ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position'); ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset'); ok(hash.item, 'UI hash includes: item'); ok(!hash.sender, 'UI hash does not include: sender'); - + }); test("change", function() { - + var hash; $("#sortable") .sortable({ change: function(e, ui) { hash = ui; } }) .find('li:eq(0)').simulate("drag", { dx: 1, dy: 1 }); - + ok(!hash, '1px drag, change event should not be triggered'); - + $("#sortable") .sortable({ change: function(e, ui) { hash = ui; } }) - .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 }); - - ok(hash, 'change event triggered'); + .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 }); + + ok(hash, 'change event triggered'); ok(hash.helper, 'UI hash includes: helper'); ok(hash.placeholder, 'UI hash includes: placeholder'); ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position'); ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset'); ok(hash.item, 'UI hash includes: item'); ok(!hash.sender, 'UI hash does not include: sender'); - + }); test("beforeStop", function() { - + var hash; $("#sortable") .sortable({ beforeStop: function(e, ui) { hash = ui; } }) - .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 }); - - ok(hash, 'beforeStop event triggered'); + .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 }); + + ok(hash, 'beforeStop event triggered'); ok(hash.helper, 'UI hash includes: helper'); ok(hash.placeholder, 'UI hash includes: placeholder'); ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position'); ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset'); ok(hash.item, 'UI hash includes: item'); ok(!hash.sender, 'UI hash does not include: sender'); - + }); test("stop", function() { - + var hash; $("#sortable") .sortable({ stop: function(e, ui) { hash = ui; } }) - .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 }); - - ok(hash, 'stop event triggered'); + .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 }); + + ok(hash, 'stop event triggered'); ok(!hash.helper, 'UI should not include: helper'); ok(hash.placeholder, 'UI hash includes: placeholder'); ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position'); ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset'); ok(hash.item, 'UI hash includes: item'); ok(!hash.sender, 'UI hash does not include: sender'); - + }); test("update", function() { - + var hash; $("#sortable") .sortable({ update: function(e, ui) { hash = ui; } }) .find('li:eq(0)').simulate("drag", { dx: 1, dy: 1 }); - + ok(!hash, '1px drag, update event should not be triggered'); - + $("#sortable") .sortable({ update: function(e, ui) { hash = ui; } }) - .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 }); - - ok(hash, 'update event triggered'); + .find('li:eq(0)').simulate("drag", { dx: 0, dy: 20 }); + + ok(hash, 'update event triggered'); ok(!hash.helper, 'UI hash should not include: helper'); ok(hash.placeholder, 'UI hash includes: placeholder'); ok(hash.position && (hash.position.top && hash.position.left), 'UI hash includes: position'); ok(hash.offset && (hash.offset.top && hash.offset.left), 'UI hash includes: offset'); ok(hash.item, 'UI hash includes: item'); ok(!hash.sender, 'UI hash does not include: sender'); - + }); test("receive", function() { diff --git a/tests/unit/sortable/sortable_methods.js b/tests/unit/sortable/sortable_methods.js index 2446d2755..c2a0b9548 100644 --- a/tests/unit/sortable/sortable_methods.js +++ b/tests/unit/sortable/sortable_methods.js @@ -5,7 +5,7 @@ var el, offsetBefore, offsetAfter, dragged; -var drag = function(handle, dx, dy) { +function drag(handle, dx, dy) { offsetBefore = $(handle).offset(); $(handle).simulate("drag", { dx: dx || 0, @@ -15,7 +15,7 @@ var drag = function(handle, dx, dy) { offsetAfter = $(handle).offset(); } -var sort = function(handle, dx, dy, index, msg) { +function sort(handle, dx, dy, index, msg) { drag(handle, dx, dy); equal($(handle).parent().children().index(handle), index, msg); } diff --git a/tests/unit/sortable/sortable_tickets.js b/tests/unit/sortable/sortable_tickets.js index 6ee503a58..22ad61baf 100644 --- a/tests/unit/sortable/sortable_tickets.js +++ b/tests/unit/sortable/sortable_tickets.js @@ -5,7 +5,7 @@ var el, offsetBefore, offsetAfter, dragged; -var drag = function(handle, dx, dy) { +function drag(handle, dx, dy) { offsetBefore = $(handle).offset(); $(handle).simulate("drag", { dx: dx || 0, @@ -15,7 +15,7 @@ var drag = function(handle, dx, dy) { offsetAfter = $(handle).offset(); } -var sort = function(handle, dx, dy, index, msg) { +function sort(handle, dx, dy, index, msg) { drag(handle, dx, dy); equal($(handle).parent().children().index(handle), index, msg); } -- 2.39.5