From c3f7aa0c0fd4603c6035ee3f0600c6bc821b7194 Mon Sep 17 00:00:00 2001 From: Facundo Paredes Date: Mon, 7 Oct 2024 13:18:56 -0300 Subject: [PATCH] Add bbox text test --- test/010-bbox-text.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 test/010-bbox-text.js diff --git a/test/010-bbox-text.js b/test/010-bbox-text.js new file mode 100644 index 0000000..fa2699f --- /dev/null +++ b/test/010-bbox-text.js @@ -0,0 +1,20 @@ +import { createSVGWindow } from "../main-module.js" +import assert from 'assert' +import { getSegments } from "../src/utils/bboxUtils.js" + +describe('bbox-text', () => { + it("text doesn't return NaN in Box values", () => { + const svgDoc = createSVGWindow().document + const svgRoot = svgDoc.documentElement + const text = svgDoc.createElement('text') + text.style.fontSize = '16px'; + text.textContent = 'F' + + svgRoot.appendChild(text) + const bboxText = getSegments(text).bbox(); + + ['left', 'x', 'top', 'y', 'width', 'height', 'right', 'bottom'].forEach((property) => { + assert(!isNaN(bboxText[property])); + }) + }) +})