X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2Fplugins.js;fp=auto_tests%2Ftests%2Fplugins.js;h=1abccd470443332603ea0be60f730f6f0f0d141d;hb=3123ca57f71d145bb5bcc4a2f754d3dff3225346;hp=36051137223a2ac10d545674376469cf354a5381;hpb=26ee953643ccd2d32e38e6b60b20e6a01c1dc9ba;p=dygraphs.git diff --git a/auto_tests/tests/plugins.js b/auto_tests/tests/plugins.js index 3605113..1abccd4 100644 --- a/auto_tests/tests/plugins.js +++ b/auto_tests/tests/plugins.js @@ -3,23 +3,25 @@ * * @author konigsberg@google.com (Robert Konigsberg) */ -var pluginsTestCase = TestCase("plugins"); +describe("plugins", function() { -pluginsTestCase.prototype.setUp = function() { +var data; + +beforeEach(function() { document.body.innerHTML = "
"; - this.data = "X,Y1,Y2\n" + + data = "X,Y1,Y2\n" + "0,1,2\n" + "1,2,1\n" + "2,1,2\n" + "3,2,1\n" ; -}; +}); -pluginsTestCase.prototype.tearDown = function() { -}; +afterEach(function() { +}); -pluginsTestCase.prototype.testWillDrawChart = function() { +it('testWillDrawChart', function() { var draw = 0; var plugin = (function() { @@ -40,12 +42,12 @@ pluginsTestCase.prototype.testWillDrawChart = function() { })(); var graph = document.getElementById("graph"); - var g = new Dygraph(graph, this.data, {plugins: [plugin]}); + var g = new Dygraph(graph, data, {plugins: [plugin]}); - assertEquals(1, draw); -}; + assert.equal(1, draw); +}); -pluginsTestCase.prototype.testPassingInstance = function() { +it('testPassingInstance', function() { // You can also pass an instance of a plugin instead of a Plugin class. var draw = 0; var p = { @@ -60,12 +62,12 @@ pluginsTestCase.prototype.testPassingInstance = function() { }; var graph = document.getElementById("graph"); - var g = new Dygraph(graph, this.data, {plugins: [p]}); + var g = new Dygraph(graph, data, {plugins: [p]}); - assertEquals(1, draw); -}; + assert.equal(1, draw); +}); -pluginsTestCase.prototype.testPreventDefault = function() { +it('testPreventDefault', function() { var data1 = "X,Y\n" + "20,-1\n" + "21,0\n" + @@ -119,7 +121,7 @@ pluginsTestCase.prototype.testPreventDefault = function() { p.pointClickPreventDefault = false; p.clickPreventDefault = false; clickOnPoint(); - assertEquals([ + assert.deepEqual([ ['plugin.pointClick', 20, -1], ['pointClickCallback', 20, -1], ['plugin.click', 20], @@ -130,7 +132,7 @@ pluginsTestCase.prototype.testPreventDefault = function() { p.pointClickPreventDefault = true; p.clickPreventDefault = false; clickOnPoint(); - assertEquals([ + assert.deepEqual([ ['plugin.pointClick', 20, -1] ], events); @@ -138,14 +140,14 @@ pluginsTestCase.prototype.testPreventDefault = function() { p.pointClickPreventDefault = false; p.clickPreventDefault = true; clickOnPoint(); - assertEquals([ + assert.deepEqual([ ['plugin.pointClick', 20, -1], ['pointClickCallback', 20, -1], ['plugin.click', 20] ], events); -}; +}); -pluginsTestCase.prototype.testEventSequence = function() { +it('testEventSequence', function() { var events = []; var eventLogger = function(name) { @@ -168,10 +170,10 @@ pluginsTestCase.prototype.testEventSequence = function() { }; var graph = document.getElementById("graph"); - var g = new Dygraph(graph, this.data, {plugins: [p]}); + var g = new Dygraph(graph, data, {plugins: [p]}); // Initial draw sequence - assertEquals([ + assert.deepEqual([ "dataDidUpdate", // should dataWillUpdate be called here, too? "predraw", "clearChart", @@ -182,7 +184,7 @@ pluginsTestCase.prototype.testEventSequence = function() { // An options change triggers a redraw, but doesn't change the data. events = []; g.updateOptions({series: {Y1: {color: 'blue'}}}); - assertEquals([ + assert.deepEqual([ "predraw", "clearChart", "willDrawChart", @@ -194,7 +196,7 @@ pluginsTestCase.prototype.testEventSequence = function() { DygraphOps.dispatchMouseDown_Point(g, 100, 100, {shiftKey: true}); DygraphOps.dispatchMouseMove_Point(g, 200, 100, {shiftKey: true}); DygraphOps.dispatchMouseUp_Point(g, 200, 100, {shiftKey: true}); - assertEquals([ + assert.deepEqual([ "clearChart", "willDrawChart", "didDrawChart" @@ -202,8 +204,8 @@ pluginsTestCase.prototype.testEventSequence = function() { // New data triggers the full sequence. events = []; - g.updateOptions({file: this.data + '\n4,1,2'}); - assertEquals([ + g.updateOptions({file: data + '\n4,1,2'}); + assert.deepEqual([ "dataWillUpdate", "dataDidUpdate", "predraw", @@ -211,9 +213,9 @@ pluginsTestCase.prototype.testEventSequence = function() { "willDrawChart", "didDrawChart" ], events); -}; +}); -pluginsTestCase.prototype.testDestroyCalledInOrder = function() { +it('testDestroyCalledInOrder', function() { var destructions = []; var makePlugin = function(name) { return { @@ -225,11 +227,13 @@ pluginsTestCase.prototype.testDestroyCalledInOrder = function() { }; var graph = document.getElementById("graph"); - var g = new Dygraph(graph, this.data, { + var g = new Dygraph(graph, data, { plugins: [makePlugin('p'), makePlugin('q')] }); - assertEquals([], destructions); + assert.deepEqual([], destructions); g.destroy(); - assertEquals(['q', 'p'], destructions); -}; + assert.deepEqual(['q', 'p'], destructions); +}); + +});