Implement the NodeCanvasFactory class to execute more unit tests in Node.js

This commit is contained in:
Tim van der Meij 2019-02-10 19:29:38 +01:00
parent b6eddc40b5
commit 7c91e94b19
No known key found for this signature in database
GPG key ID: 8C3FD2925A5F2762
5 changed files with 329 additions and 29 deletions

View file

@ -13,7 +13,7 @@
* limitations under the License.
*/
import { buildGetDocumentParams } from './test_utils';
import { buildGetDocumentParams, NodeCanvasFactory } from './test_utils';
import { DOMCanvasFactory } from '../../src/display/dom_utils';
import { getDocument } from '../../src/display/api';
import isNodeJS from '../../src/shared/is_node';
@ -37,8 +37,7 @@ describe('custom canvas rendering', function() {
beforeAll(function(done) {
if (isNodeJS()) {
// NOTE: To support running the canvas-related tests in Node.js,
// a `NodeCanvasFactory` would need to be added (in test_utils.js).
CanvasFactory = new NodeCanvasFactory();
} else {
CanvasFactory = new DOMCanvasFactory();
}
@ -58,9 +57,6 @@ describe('custom canvas rendering', function() {
});
it('renders to canvas with a default white background', function(done) {
if (isNodeJS()) {
pending('TODO: Support Canvas testing in Node.js.');
}
var viewport = page.getViewport({ scale: 1, });
var canvasAndCtx = CanvasFactory.create(viewport.width, viewport.height);
@ -77,9 +73,6 @@ describe('custom canvas rendering', function() {
});
it('renders to canvas with a custom background', function(done) {
if (isNodeJS()) {
pending('TODO: Support Canvas testing in Node.js.');
}
var viewport = page.getViewport({ scale: 1, });
var canvasAndCtx = CanvasFactory.create(viewport.width, viewport.height);