Skip to content

Commit b436131

Browse files
committed
Fix tests that were failing due to text being rendered in an svg “g” group for scaling purposes
1 parent f2df4bf commit b436131

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

test/render/appendChild.spec.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ function testScale(scale = 0.5, passViewportArg = true) {
1313
x: 200,
1414
y: 100
1515
};
16-
16+
1717
let nested = appendChild(svg, annotation, passViewportArg ? viewport : undefined);
18-
18+
1919
if (isFirefox) {
2020
equal(nested.getAttribute('x'), annotation.x);
2121
equal(nested.getAttribute('y'), annotation.y);
@@ -90,13 +90,13 @@ describe('render::appendChild', function () {
9090
width: 25,
9191
height: 25
9292
}, viewport);
93-
93+
9494
equal(point.getAttribute('data-pdf-annotate-id'), '1234');
9595
equal(point.getAttribute('data-pdf-annotate-type'), 'point');
9696
equal(area.getAttribute('data-pdf-annotate-id'), '5678');
9797
equal(area.getAttribute('data-pdf-annotate-type'), 'area');
9898
});
99-
99+
100100
it('should render area', function () {
101101
let area = appendChild(svg, {
102102
type: 'area',
@@ -146,7 +146,8 @@ describe('render::appendChild', function () {
146146
});
147147

148148
it('should render textbox', function () {
149-
let textbox = appendChild(svg, {
149+
150+
let textboxGroup = appendChild(svg, {
150151
type: 'textbox',
151152
x: 125,
152153
y: 400,
@@ -156,6 +157,7 @@ describe('render::appendChild', function () {
156157
color: '000000',
157158
content: 'Lorem Ipsum'
158159
}, viewport);
160+
let textbox = textboxGroup.firstChild;
159161

160162
equal(textbox.nodeName.toLowerCase(), 'text');
161163
});

test/render/renderText.spec.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@ describe('render::renderText', function () {
77
const y = 100;
88
const size = 20;
99
const color = '000';
10-
let text = renderText({
10+
let gNode = renderText({
1111
x,
1212
y,
1313
size,
1414
color
1515
});
16+
let text = gNode.firstChild
1617

1718
equal(text.nodeName, 'text');
1819
equal(text.getAttribute('x'), x);
19-
equal(text.getAttribute('y'), y + size);
20+
equal(text.getAttribute('y'), y );
2021
equal(text.getAttribute('fill'), `#${color}`);
2122
equal(text.getAttribute('font-size'), size);
2223
});

0 commit comments

Comments
 (0)