X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Ftests%2Fformats.js;h=2548d99fd7c009b4614408d989281effa97ef8d8;hb=refs%2Ftags%2Fv2.0.0;hp=9ff3dabf84073cc0f07f6eb00b90d87960c1a43f;hpb=65129ba82d4efe12714be88fa3c792149c00ca10;p=dygraphs.git diff --git a/auto_tests/tests/formats.js b/auto_tests/tests/formats.js index 9ff3dab..2548d99 100644 --- a/auto_tests/tests/formats.js +++ b/auto_tests/tests/formats.js @@ -3,14 +3,12 @@ * * @author konigsberg@google.com (Robert Konigsberg) */ -describe("formats", function() { -beforeEach(function() { - document.body.innerHTML = "
"; -}); +import Dygraph from '../../src/dygraph'; -afterEach(function() { -}); +describe("formats", function() { + +cleanupAfterEach(); var dataString = "X,Y\n" + @@ -41,13 +39,11 @@ it('testArray', function() { }); it('testFunctionReturnsCsv', function() { - var string = dataString; - var data = function() { return string; }; + var data = function() { return dataString; }; var graph = document.getElementById("graph"); var g = new Dygraph(graph, data, {}); - // assertData(g); - console.log("x"); + assertData(g); }); it('testFunctionDefinesArray', function() { @@ -81,6 +77,16 @@ it('testXValueParser', function() { assert.equal(6, g.getValue(3, 0)); }); +it('should throw on strings in native format', () => { + assert.throws(() => { + new Dygraph('graph', [['1', '10'], ['2', '20']]) + }, /expected number or date/i); + + assert.throws(() => { + new Dygraph('graph', [[new Date(), '10'], [new Date(), '20']]) + }, /expected number or array/i); +}); + var assertData = function(g) { var expected = dataArray;