Skip to content

Commit 8cb0763

Browse files
committed
Merge pull request mathjax#114 from pkra/tape
Add Tape tests
2 parents e8c7cd7 + c9e3ade commit 8cb0763

File tree

7 files changed

+107
-29
lines changed

7 files changed

+107
-29
lines changed

.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
language: node_js
2+
node_js:
3+
- 'iojs'
4+
sudo: false
5+
script:
6+
- npm install
7+
- npm test

lib/mj-page.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ function ConfigureMathJax() {
290290
jax.SVG.ex = ex = (data||defaults).ex;
291291
jax.SVG.em = em = ex / SVG.TeX.x_height * 1000; // scale ex to x_height
292292
jax.SVG.cwidth = width / em * 1000;
293-
jax.SVG.lineWidth = (linebreak ? width / em *1000 : 1000000);
293+
jax.SVG.lineWidth = (linebreak ? width / em *1000 : SVG.BIGDIMEN);
294294
}
295295
//
296296
// Set state variables used for displaying equations in chunks
@@ -526,7 +526,7 @@ function ConfigureTypeset() {
526526
// Configure SVG and TeX
527527
//
528528
SVG.defaultEx = data.ex;
529-
SVG.defaultWidth = data.width;
529+
SVG.defaultWidth = data.width * data.ex;
530530
SVG.config.linebreaks.automatic = data.linebreaks;
531531
SVG.config.linebreaks.width = data.width * data.ex;
532532
SVG.config.useFontCache = data.useFontCache;

lib/mj-single.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ function ConfigureMathJax() {
285285
jax.SVG.ex = ex = (data||defaults).ex;
286286
jax.SVG.em = em = ex / SVG.TeX.x_height * 1000; // scale ex to x_height
287287
jax.SVG.cwidth = width / em * 1000;
288-
jax.SVG.lineWidth = (linebreak ? width / em * 1000 : 1000000);
288+
jax.SVG.lineWidth = (linebreak ? width / em * 1000 : SVG.BIGDIMEN);
289289
}
290290
//
291291
// Set state variables used for displaying equations in chunks
@@ -555,7 +555,7 @@ function StartQueue() {
555555
HUB = MathJax.Hub;
556556

557557
SVG.defaultEx = data.ex;
558-
SVG.defaultWidth = data.width;
558+
SVG.defaultWidth = data.width * data.ex;
559559
SVG.config.linebreaks.automatic = data.linebreaks;
560560
SVG.config.linebreaks.width = data.width * data.ex;
561561
SVG.config.useFontCache = data.useFontCache;

package.json

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,40 @@
11
{
2-
"name": "MathJax-node",
3-
"version": "0.3.0",
4-
"description": "API's for calling MathJax from node.js",
5-
"keywords": ["MathJax","math","svg","MathML","TeX","AsciiMath"],
6-
"maintainers": [
7-
"MathJax Consortium <[email protected]> (http://www.mathjax.org)"
8-
],
9-
"bugs": {
10-
"url": "http://github.com/mathjax/MathJax-node/issues"
11-
},
12-
"license": {
13-
"type": "Apache-2.0",
14-
"url": "http://github.com/mathjax/MathJax-node/blob/master/LICENSE"
15-
},
16-
"repository": {
17-
"type": "git",
18-
"url": "git://github.com/mathjax/MathJax-node.git"
19-
},
20-
"dependencies": {
21-
"jsdom": "*",
22-
"speech-rule-engine": "*",
23-
"yargs": "*",
24-
"MathJax": "https://github.com/mathjax/MathJax/tarball/mathjax-node-2.5.1"
25-
},
26-
"main": "./lib/mj-page.js"
2+
"name": "MathJax-node",
3+
"version": "0.3.0",
4+
"description": "API's for calling MathJax from node.js",
5+
"keywords": [
6+
"MathJax",
7+
"math",
8+
"svg",
9+
"MathML",
10+
"TeX",
11+
"AsciiMath"
12+
],
13+
"maintainers": [
14+
"MathJax Consortium <[email protected]> (http://www.mathjax.org)"
15+
],
16+
"bugs": {
17+
"url": "http://github.com/mathjax/MathJax-node/issues"
18+
},
19+
"license": {
20+
"type": "Apache-2.0",
21+
"url": "http://github.com/mathjax/MathJax-node/blob/master/LICENSE"
22+
},
23+
"repository": {
24+
"type": "git",
25+
"url": "git://github.com/mathjax/MathJax-node.git"
26+
},
27+
"dependencies": {
28+
"jsdom": "*",
29+
"speech-rule-engine": "*",
30+
"yargs": "*",
31+
"MathJax": "https://github.com/mathjax/MathJax/tarball/mathjax-node-2.5.1"
32+
},
33+
"scripts": {
34+
"test": "tape test/*.js"
35+
},
36+
"main": "./lib/mj-page.js",
37+
"devDependencies": {
38+
"tape": "^4.0.3"
39+
}
2740
}

test/base-mathjax.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
var tape = require('tape');
2+
var mjAPI = require("..//lib/mj-single.js");
3+
4+
tape('basic test: check MathJax core', function(t) {
5+
t.plan(1);
6+
7+
var tex = '';
8+
mjAPI.start();
9+
10+
mjAPI.typeset({
11+
math: tex,
12+
format: "TeX",
13+
mml: true
14+
}, function(data) {
15+
t.ok(data.mml, 'MathJax core seems ok');
16+
});
17+
});

test/base-speechruleengine.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var tape = require('tape');
2+
var mjAPI = require("..//lib/mj-single.js");
3+
4+
tape('basic test: check speechruleengine', function(t) {
5+
t.plan(1);
6+
7+
var tex = 'MathJax';
8+
mjAPI.start();
9+
10+
mjAPI.typeset({
11+
math: tex,
12+
format: "TeX",
13+
mml: true,
14+
speakText: true
15+
}, function(data) {
16+
t.ok(data.speakText, 'speechruleengine seems ok');
17+
});
18+
});

test/issue104.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
var tape = require('tape');
2+
var mjAPI = require("..//lib/mj-single.js");
3+
var jsdom = require('jsdom').jsdom;
4+
5+
tape('the SVG width should match the default', function(t) {
6+
t.plan(1);
7+
8+
mjAPI.start();
9+
var tex = 'a \\\\ b';
10+
var expected = '100ex';
11+
12+
mjAPI.typeset({
13+
math: tex,
14+
format: "TeX",
15+
svg: true
16+
}, function(data) {
17+
var document = jsdom(data.svg);
18+
var window = document.defaultView;
19+
var element = window.document.getElementsByTagName("svg")[0];
20+
var width = element.getAttribute('width');
21+
t.equal(width, expected);
22+
});
23+
});

0 commit comments

Comments
 (0)