Commit | Line | Data |
---|---|---|
cb8bb6a6 DV |
1 | /** |
2 | * @fileoverview Tests for window.devicePixelRatio > 1. | |
3 | * | |
4 | * @author danvdk@gmail.com (Dan Vanderkam) | |
5 | */ | |
e8c70e4e DV |
6 | |
7 | import Dygraph from '../../src/dygraph'; | |
8 | ||
89fdcedb | 9 | describe("hidpi", function() { |
cb8bb6a6 | 10 | |
e8c70e4e DV |
11 | cleanupAfterEach(); |
12 | ||
cb8bb6a6 | 13 | var savePixelRatio; |
89fdcedb | 14 | beforeEach(function() { |
cb8bb6a6 DV |
15 | savePixelRatio = window.devicePixelRatio; |
16 | window.devicePixelRatio = 2; | |
89fdcedb | 17 | }); |
cb8bb6a6 | 18 | |
89fdcedb | 19 | afterEach(function() { |
cb8bb6a6 | 20 | window.devicePixelRatio = savePixelRatio; |
89fdcedb | 21 | }); |
cb8bb6a6 | 22 | |
89fdcedb | 23 | it('testDoesntCreateScrollbars', function() { |
5fc89353 PH |
24 | var sw = document.body.scrollWidth; |
25 | var cw = document.body.clientWidth; | |
26 | ||
cb8bb6a6 DV |
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 | ||
5fc89353 PH |
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) | |
cb8bb6a6 | 43 | // See http://stackoverflow.com/a/2146905/388951 |
89fdcedb DV |
44 | assert.equal(cw, document.body.clientWidth); |
45 | assert.equal(sw, document.body.scrollWidth); | |
46 | }); | |
cb8bb6a6 | 47 | |
89fdcedb DV |
48 | |
49 | }); |