Skip to content

Commit db88784

Browse files
committed
Add test for adding class prior to rendering (niklasvh#508)
1 parent 77c73c4 commit db88784

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

tests/mocha/options.onclone.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,21 @@
77
<script src="../assets/jquery-1.6.2.js"></script>
88
<script src="lib/expect.js"></script>
99
<script src="lib/mocha.js"></script>
10+
<style>
11+
#block2 {
12+
background: red;
13+
}
14+
15+
.my-css-class #block2 {
16+
background: green;
17+
}
18+
</style>
1019
</head>
1120
<body>
1221
<div id="mocha"></div>
1322
<script>mocha.setup('bdd')</script>
1423
<div style="background: red; width: 200px; height:200px;" id="block"></div>
24+
<div style="width: 200px; height:200px;" id="block2"></div>
1525
<script>
1626
describe("options.onclone", function() {
1727
it("with a function", function(done) {
@@ -46,6 +56,19 @@
4656
done(error);
4757
});
4858
});
59+
60+
it("add class to node", function(done) {
61+
html2canvas(document.querySelector("#block2"), {onclone: function(document) {
62+
document.documentElement.className = "my-css-class";
63+
}}).then(function(canvas) {
64+
expect(canvas.width).to.equal(200);
65+
expect(canvas.height).to.equal(200);
66+
validCanvasPixels(canvas);
67+
done();
68+
}).catch(function(error) {
69+
done(error);
70+
});
71+
});
4972
});
5073

5174
function validCanvasPixels(canvas) {

0 commit comments

Comments
 (0)