Skip to content

Commit add9452

Browse files
committed
Convert get-bounds test to typescript
1 parent c609e0d commit add9452

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed
Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import * as txt from "txt";
2+
import * as txtExamples from "examples";
3+
import { removeCanvas } from "./helpers";
14
describe("Text", function() {
2-
var canvas;
3-
var stage;
5+
let canvas;
6+
let stage;
47
beforeEach(function() {
58
canvas = txtExamples.createHiDPICanvas(300, 300, 2);
69
document.body.appendChild(canvas);
@@ -9,20 +12,20 @@ describe("Text", function() {
912
});
1013

1114
afterEach(function() {
12-
txtExamples.clearExample();
15+
removeCanvas();
1316
});
1417

1518
it("getBounds of Glyph", function() {
16-
var glyph = new txt.Glyph();
19+
const glyph = new txt.Glyph();
1720
glyph.offset = 1063 / 2048;
1821
glyph.path =
1922
"M492 -246v226q-72 1 -136 28.5t-111 75t-74.5 111.5t-27.5 137v57l129 21v-78q0 -47 17 -88t47 -72t70 -49.5t86 -20.5v582q-66 24 -128.5 52.5t-111.5 72.5t-79 108t-30 158v27q0 72 27.5 135.5t74.5 111.5t111 76t136 29v184h102v-184q71 -1 134 -29.5t110 -76 t74.5 -111t27.5 -135.5v-37l-129 -21v58q0 46 -17 87t-46 71.5t-69 49.5t-85 21v-555q65 -25 129 -55t114.5 -75t81.5 -110.5t31 -160.5v-43q0 -73 -27.5 -137t-75.5 -112t-112 -75.5t-137 -27.5h-4v-226h-102zM821 375q0 57 -18 99.5t-48.5 74t-72 54.5t-88.5 42v-543 q47 0 88.5 18t72 49.5t48.5 73t18 89.5v43v0zM272 1075q0 -53 17 -92.5t47 -69.5t70 -53t86 -43v514q-46 -2 -86 -21t-70 -49.5t-47 -71.5t-17 -87v-27v0z";
20-
var bounds = glyph.getBounds();
23+
const bounds = glyph.getBounds();
2124
expect(bounds.width).toBeGreaterThan(0);
2225
});
2326

2427
it("getBounds of Text", function() {
25-
var text = new txt.Text({
28+
const text = new txt.Text({
2629
text: "First poiretone",
2730
font: "poiretone",
2831
width: 400,
@@ -35,7 +38,7 @@ describe("Text", function() {
3538

3639
stage.addChild(text);
3740

38-
var bounds = text.getBounds();
41+
const bounds = text.getBounds();
3942

4043
expect(bounds).not.toBeNull();
4144

0 commit comments

Comments
 (0)