Migrate most of core dygraphs to ES6 modules.
[dygraphs.git] / auto_tests / tests / hidpi.js
CommitLineData
cb8bb6a6
DV
1/**
2 * @fileoverview Tests for window.devicePixelRatio > 1.
3 *
4 * @author danvdk@gmail.com (Dan Vanderkam)
5 */
89fdcedb 6describe("hidpi", function() {
cb8bb6a6
DV
7
8var savePixelRatio;
89fdcedb 9beforeEach(function() {
cb8bb6a6
DV
10 savePixelRatio = window.devicePixelRatio;
11 window.devicePixelRatio = 2;
12
13 document.body.innerHTML = "<div id='graph'></div>";
89fdcedb 14});
cb8bb6a6 15
89fdcedb 16afterEach(function() {
cb8bb6a6 17 window.devicePixelRatio = savePixelRatio;
89fdcedb 18});
cb8bb6a6 19
89fdcedb 20it('testDoesntCreateScrollbars', function() {
5fc89353
PH
21 var sw = document.body.scrollWidth;
22 var cw = document.body.clientWidth;
23
cb8bb6a6
DV
24 var graph = document.getElementById("graph");
25 graph.style.width = "70%"; // more than half.
26 graph.style.height = "200px";
27
28 var opts = {};
29 var data = "X,Y\n" +
30 "0,-1\n" +
31 "1,0\n" +
32 "2,1\n" +
33 "3,0\n"
34 ;
35
36 var g = new Dygraph(graph, data, opts);
37
5fc89353
PH
38 // Adding the graph shouldn't cause the width of the page to change.
39 // (essentially, we're checking that we don't end up with a scrollbar)
cb8bb6a6 40 // See http://stackoverflow.com/a/2146905/388951
89fdcedb
DV
41 assert.equal(cw, document.body.clientWidth);
42 assert.equal(sw, document.body.scrollWidth);
43});
cb8bb6a6 44
89fdcedb
DV
45
46});