ba06e61a761fc6b8dfc974ad1b8cf6eb3264a42f
2 * @fileoverview Tests involving issuing XHRs for data.
4 * Note that these tests must be run with an HTTP server.
5 * XHRs can't be issued from file:/// URLs.
6 * This can be done with
8 * npm install http-server
10 * open http://localhost:8080/auto_tests/runner.html
14 import Dygraph from
'../../src/dygraph';
15 import Util from
'./Util';
17 import 'core-js/es6/promise';
19 function dygraphPromise(div
, data
, opts
) {
20 return new Promise((resolve
, reject
) => {
21 const g
= new Dygraph(div
, data
, opts
);
22 g
.ready(() => resolve(g
));
26 describe("xhr", () => {
28 it('should issue XHRs for CSV data', () => {
29 return dygraphPromise('graph', 'data/sample.csv').then(g
=> {
31 assert
.equal(g
.numRows(), 4);
32 assert
.equal(g
.numColumns(), 3);
36 it('should warn on out-of-order CSV data', () => {
38 const restore
= Util
.captureConsole(calls
);
39 return dygraphPromise('graph', 'data/out-of-order.csv').then(g
=> {
42 assert
.equal(g
.numRows(), 4);
43 assert
.equal(g
.numColumns(), 3);
44 assert
.equal(calls
.warn
.length
, 1);
45 assert(/out of order/.exec(calls
.warn
[0]));
48 return Promise
.reject(e
);
52 it('should warn on out-of-order CSV data with dates', () => {
54 const restore
= Util
.captureConsole(calls
);
55 return dygraphPromise('graph', 'data/out-of-order-dates.csv').then(g
=> {
58 assert
.equal(g
.numRows(), 8);
59 assert
.equal(g
.numColumns(), 5);
60 assert
.equal(calls
.warn
.length
, 1);
61 assert(/out of order/.exec(calls
.warn
[0]));
64 return Promise
.reject(e
);