From 51cb170017f49815412286508733037dcef6e827 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E4=B8=9D?= Date: Wed, 20 Sep 2023 20:30:32 +0800 Subject: [PATCH 1/2] test: fix test image timeout --- __test__/index.spec.ts | 4 ++-- __test__/wasm.spec.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/__test__/index.spec.ts b/__test__/index.spec.ts index 52c65d78..3d427064 100755 --- a/__test__/index.spec.ts +++ b/__test__/index.spec.ts @@ -10,9 +10,9 @@ import { Resvg, renderAsync } from '../index' import { jimpToRgbaPixels } from './helper' test('Use href to load a JPG image without alpha', async (t) => { - const imgUrl = 'https://himg.bdimg.com/sys/portrait/hotitem/wildkid/46' + const imgUrl = 'https://wd.imgix.net/image/kheDArv5csY6rvQUJDbWRscckLr1/De5peVXJZz3uSEmmVeYJ.png?w=500' const svg = ` - + ` const resvg = new Resvg(svg, { font: { diff --git a/__test__/wasm.spec.ts b/__test__/wasm.spec.ts index aa9daeaa..d67a736e 100755 --- a/__test__/wasm.spec.ts +++ b/__test__/wasm.spec.ts @@ -16,9 +16,9 @@ test.before(async () => { }) test('Use href to load a JPG image without alpha', async (t) => { - const imgUrl = 'https://himg.bdimg.com/sys/portrait/hotitem/wildkid/46' + const imgUrl = 'https://wd.imgix.net/image/kheDArv5csY6rvQUJDbWRscckLr1/De5peVXJZz3uSEmmVeYJ.png?w=500' const svg = ` - + ` const resvg = new Resvg(svg) const resolved = await Promise.all( From eb26bf4ad8ab88c8bd032a01cf93a7152f7e7741 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E4=B8=9D?= Date: Wed, 20 Sep 2023 21:02:18 +0800 Subject: [PATCH 2/2] test: using simple SVG files to make testing faster text.svg => bbox.svg --- __test__/index.spec.ts | 20 ++++++++++---------- __test__/wasm.spec.ts | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/__test__/index.spec.ts b/__test__/index.spec.ts index 3d427064..bb4f73a2 100755 --- a/__test__/index.spec.ts +++ b/__test__/index.spec.ts @@ -87,25 +87,25 @@ test('svg to RGBA pixels Array', async (t) => { }) test('fit to width', async (t) => { - const filePath = '../example/text.svg' + const filePath = '../example/bbox.svg' const svg = await fs.readFile(join(__dirname, filePath)) const resvg = new Resvg(svg, { background: '#eeebe6', fitTo: { mode: 'width', - value: 1200, + value: 800, }, }) const pngData = resvg.render() const pngBuffer = pngData.asPng() const result = await jimp.read(pngBuffer) - t.is(result.getWidth(), 1200) - t.is(result.getHeight(), 623) + t.is(result.getWidth(), 800) + t.is(result.getHeight(), 1156) }) test('fit to height', async (t) => { - const filePath = '../example/text.svg' + const filePath = '../example/bbox.svg' const svg = await fs.readFile(join(__dirname, filePath)) const resvg = new Resvg(svg, { background: '#eeebe6', @@ -118,23 +118,23 @@ test('fit to height', async (t) => { const pngBuffer = pngData.asPng() const result = await jimp.read(pngBuffer) - t.is(result.getWidth(), 1003) + t.is(result.getWidth(), 360) t.is(result.getHeight(), 520) }) test('Get SVG original size', async (t) => { - const filePath = '../example/text.svg' + const filePath = '../example/bbox.svg' const svg = await fs.readFile(join(__dirname, filePath)) const resvg = new Resvg(svg, { background: '#eeebe6', fitTo: { mode: 'width', - value: 1200, // The original size is not affected by the fitTo parameter + value: 600, // The original size is not affected by the fitTo parameter }, }) - t.is(resvg.width, 1324) - t.is(resvg.height, 687) + t.is(resvg.width, 180) + t.is(resvg.height, 260) }) test('SVG size must be rounded to an integer', (t) => { diff --git a/__test__/wasm.spec.ts b/__test__/wasm.spec.ts index d67a736e..cdd6c054 100755 --- a/__test__/wasm.spec.ts +++ b/__test__/wasm.spec.ts @@ -101,14 +101,14 @@ test('buffer input', async (t) => { }) test('fit to width', async (t) => { - const filePath = '../example/text.svg' + const filePath = '../example/bbox.svg' const svg = await fs.readFile(join(__dirname, filePath)) const svgString = svg.toString('utf-8') const opts = { background: '#eeebe6', fitTo: { mode: 'width', - value: 1200, + value: 800, }, } const resvg = new Resvg(svgString, opts) @@ -116,12 +116,12 @@ test('fit to width', async (t) => { const pngBuffer = pngData.asPng() const result = await jimp.read(Buffer.from(pngBuffer)) - t.is(result.getWidth(), 1200) - t.is(result.getHeight(), 623) + t.is(result.getWidth(), 800) + t.is(result.getHeight(), 1156) }) test('fit to height', async (t) => { - const filePath = '../example/text.svg' + const filePath = '../example/bbox.svg' const svg = await fs.readFile(join(__dirname, filePath)) const svgString = svg.toString('utf-8') const opts = { @@ -136,23 +136,23 @@ test('fit to height', async (t) => { const pngBuffer = pngData.asPng() const result = await jimp.read(Buffer.from(pngBuffer)) - t.is(result.getWidth(), 1003) + t.is(result.getWidth(), 360) t.is(result.getHeight(), 520) }) test('Get SVG original size', async (t) => { - const filePath = '../example/text.svg' + const filePath = '../example/bbox.svg' const svg = await fs.readFile(join(__dirname, filePath)) const resvg = new Resvg(svg, { background: '#eeebe6', fitTo: { mode: 'width', - value: 1200, // The original size is not affected by the fitTo parameter + value: 600, // The original size is not affected by the fitTo parameter }, }) - t.is(resvg.width, 1324) - t.is(resvg.height, 687) + t.is(resvg.width, 180) + t.is(resvg.height, 260) }) test('SVG size must be rounded to an integer', (t) => {