Skip to content

Commit 778f723

Browse files
committed
move loadImage test to image.test.js
1 parent fbac0f6 commit 778f723

2 files changed

Lines changed: 15 additions & 16 deletions

File tree

‎test/canvas.test.js‎

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2674,20 +2674,4 @@ describe('Canvas', function () {
26742674
assert.throws(() => { ctx.beginTag('Link', {}) })
26752675
})
26762676
})
2677-
2678-
describe('loadImage', function () {
2679-
it('doesn\'t crash when you don\'t specify width and height', async function () {
2680-
const err = {name: "Error"};
2681-
2682-
// TODO: remove this when we have a static build or something
2683-
if (os.platform() !== 'win32') {
2684-
err.message = "Width and height must be set on the svg element";
2685-
}
2686-
2687-
await assert.rejects(async () => {
2688-
const svg = `<svg xmlns="http://www.w3.org/2000/svg"><path d="M1,1"/></svg>`;
2689-
await loadImage(Buffer.from(svg));
2690-
}, err);
2691-
});
2692-
});
26932677
})

‎test/image.test.js‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const assert = require('assert')
99
const assertRejects = require('assert-rejects')
1010
const fs = require('fs')
1111
const path = require('path')
12+
const os = require('os')
1213

1314
const { createCanvas, loadImage, rsvgVersion, Image } = require('../')
1415
const HAVE_SVG = rsvgVersion !== undefined
@@ -345,6 +346,20 @@ describe('Image', function () {
345346
assert.ok(!keys.includes('setSource'))
346347
})
347348

349+
it('loadImage doesn\'t crash when you don\'t specify width and height', async function () {
350+
const err = {name: 'Error'}
351+
352+
// TODO: remove this when we have a static build or something
353+
if (os.platform() !== 'win32') {
354+
err.message = 'Width and height must be set on the svg element';
355+
}
356+
357+
await assert.rejects(async () => {
358+
const svg = `<svg xmlns="http://www.w3.org/2000/svg"><path d="M1,1"/></svg>`;
359+
await loadImage(Buffer.from(svg))
360+
}, err)
361+
})
362+
348363
describe('supports BMP', function () {
349364
it('parses 1-bit image', function (done) {
350365
const img = new Image()

0 commit comments

Comments
 (0)