X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2Fpathological_cases.js;h=297167c806c673345a13ef26f943b69005909361;hb=9e149228bdffc9d916b9b24ce972667d918e388a;hp=ade714c8a888243dcadb48c24db565925a10c0ae;hpb=89fdcedbda6906d90e15d84285c4f6c0b8d96d28;p=dygraphs.git diff --git a/auto_tests/tests/pathological_cases.js b/auto_tests/tests/pathological_cases.js index ade714c..297167c 100644 --- a/auto_tests/tests/pathological_cases.js +++ b/auto_tests/tests/pathological_cases.js @@ -6,11 +6,15 @@ */ describe("pathological-cases", function() { +var restoreConsole; +var logs = {}; beforeEach(function() { document.body.innerHTML = "
"; + restoreConsole = Util.captureConsole(logs); }); afterEach(function() { + restoreConsole(); }); it('testZeroPoint', function() { @@ -111,6 +115,16 @@ it('testCombinations', function() { opts.labels = ['X', 'A', 'B', 'C'].slice(0, cols); var g = new Dygraph(gdiv, data, opts); + + if (dataName == 'empty') { + assert.deepEqual(logs, { + log: [], warn: [], + error: ["Can't plot empty data set"] + }); + logs.error = []; // reset + } else { + assert.deepEqual(logs, {log: [], warn: [], error: []}); + } } } } @@ -160,4 +174,18 @@ it('testConstantSeriesNegativeIncludeZero', function() { assert.deepEqual([-1.1, 0], g.yAxisRange()); }); +it('should throw with non-existent divs', function() { + var data = "X,Y\n" + + "1,-1\n" + + "2,1\n"; + + assert.throws(function() { + new Dygraph(null, data); + }, /non-existent div/); + + assert.throws(function() { + new Dygraph('non-existent-div-id', data); + }, /non-existent div/); +}); + });