90712fadb965a1752e5e35bbec89d43ca2ef90eb
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 function dygraphPromise(div
, data
, opts
) {
18 return new Promise((resolve
, reject
) => {
19 const g
= new Dygraph(div
, data
, opts
);
20 g
.ready(() => resolve(g
));
24 describe("xhr", () => {
26 it('should issue XHRs for CSV data', () => {
27 return dygraphPromise('graph', 'data/sample.csv').then(g
=> {
29 assert
.equal(g
.numRows(), 4);
30 assert
.equal(g
.numColumns(), 3);
34 it('should warn on out-of-order CSV data', () => {
36 const restore
= Util
.captureConsole(calls
);
37 return dygraphPromise('graph', 'data/out-of-order.csv').then(g
=> {
40 assert
.equal(g
.numRows(), 4);
41 assert
.equal(g
.numColumns(), 3);
42 assert
.equal(calls
.warn
.length
, 1);
43 assert(/out of order/.exec(calls
.warn
[0]));
46 return Promise
.reject(e
);
50 it('should warn on out-of-order CSV data with dates', () => {
52 const restore
= Util
.captureConsole(calls
);
53 return dygraphPromise('graph', 'data/out-of-order-dates.csv').then(g
=> {
56 assert
.equal(g
.numRows(), 8);
57 assert
.equal(g
.numColumns(), 5);
58 assert
.equal(calls
.warn
.length
, 1);
59 assert(/out of order/.exec(calls
.warn
[0]));
62 return Promise
.reject(e
);