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