Add test for adding class prior to rendering (#508)

This commit is contained in:
Niklas von Hertzen 2015-01-19 20:31:31 +02:00
parent 77c73c478f
commit db88784655

View File

@ -7,11 +7,21 @@
<script src="../assets/jquery-1.6.2.js"></script>
<script src="lib/expect.js"></script>
<script src="lib/mocha.js"></script>
<style>
#block2 {
background: red;
}
.my-css-class #block2 {
background: green;
}
</style>
</head>
<body>
<div id="mocha"></div>
<script>mocha.setup('bdd')</script>
<div style="background: red; width: 200px; height:200px;" id="block"></div>
<div style="width: 200px; height:200px;" id="block2"></div>
<script>
describe("options.onclone", function() {
it("with a function", function(done) {
@ -46,6 +56,19 @@
done(error);
});
});
it("add class to node", function(done) {
html2canvas(document.querySelector("#block2"), {onclone: function(document) {
document.documentElement.className = "my-css-class";
}}).then(function(canvas) {
expect(canvas.width).to.equal(200);
expect(canvas.height).to.equal(200);
validCanvasPixels(canvas);
done();
}).catch(function(error) {
done(error);
});
});
});
function validCanvasPixels(canvas) {