Switch from jasmine-node to jasmine itself

Jasmine supports node these days, so there is no longer a need to use a
separate (and unmaintained) package to provide such bindings.

Making the switch exposed several misuses of the `toMatch` assertion in the
existing specification.  Most of them were converted to `toEqual`, since
`toMatch` is only for matching against regular expressions.
This commit is contained in:
Martin von Gagern 2015-11-10 12:29:00 +01:00
parent 21a26b807c
commit 92034c17f9
4 changed files with 97 additions and 88 deletions

View File

@ -76,8 +76,7 @@ serve:
node server.js
test:
./node_modules/.bin/jasmine-node test/katex-spec.js
./node_modules/.bin/jasmine-node contrib/auto-render/auto-render-spec.js
JASMINE_CONFIG_PATH=test/jasmine.json node_modules/.bin/jasmine
PERL=perl
PYTHON=$(shell python2 --version >/dev/null 2>&1 && echo python2 || echo python)

View File

@ -17,13 +17,13 @@
"browserify": "^10.2.4",
"clean-css": "~2.2.15",
"express": "~3.3.3",
"jasmine-node": "2.0.0-beta4",
"jasmine": "^2.3.2",
"js-yaml": "^3.3.1",
"jshint": "^2.5.6",
"jspngopt": "^0.1.0",
"less": "~1.7.5",
"pako": "0.2.7",
"nomnom": "^1.8.1",
"pako": "0.2.7",
"selenium-webdriver": "^2.46.1",
"uglify-js": "~2.4.15"
},

10
test/jasmine.json Normal file
View File

@ -0,0 +1,10 @@
{
"spec_dir": ".",
"spec_files": [
"test/**/*[sS]pec.js",
"contrib/**/*[sS]pec.js"
],
"helpers": [
"helpers/**/*.js"
]
}

View File

@ -197,7 +197,7 @@ describe("A bin parser", function() {
for (var i = 0; i < parse.length; i++) {
var group = parse[i];
expect(group.type).toMatch("bin");
expect(group.type).toEqual("bin");
}
});
});
@ -215,7 +215,7 @@ describe("A rel parser", function() {
for (var i = 0; i < parse.length; i++) {
var group = parse[i];
expect(group.type).toMatch("rel");
expect(group.type).toEqual("rel");
}
});
});
@ -233,7 +233,7 @@ describe("A punct parser", function() {
for (var i = 0; i < parse.length; i++) {
var group = parse[i];
expect(group.type).toMatch("punct");
expect(group.type).toEqual("punct");
}
});
});
@ -251,7 +251,7 @@ describe("An open parser", function() {
for (var i = 0; i < parse.length; i++) {
var group = parse[i];
expect(group.type).toMatch("open");
expect(group.type).toEqual("open");
}
});
});
@ -269,7 +269,7 @@ describe("A close parser", function() {
for (var i = 0; i < parse.length; i++) {
var group = parse[i];
expect(group.type).toMatch("close");
expect(group.type).toEqual("close");
}
});
});
@ -458,7 +458,7 @@ describe("An implicit group parser", function() {
var sizing = parse[0];
expect(sizing.type).toMatch("sizing");
expect(sizing.type).toEqual("sizing");
expect(sizing.value).toBeTruthy();
});
@ -469,7 +469,7 @@ describe("An implicit group parser", function() {
var sizing = parse[1];
expect(sizing.type).toMatch("sizing");
expect(sizing.type).toEqual("sizing");
expect(sizing.value.value.length).toBe(3);
});
@ -479,7 +479,7 @@ describe("An implicit group parser", function() {
var group = parse[1];
var sizing = group.value[1];
expect(sizing.type).toMatch("sizing");
expect(sizing.type).toEqual("sizing");
expect(sizing.value.value.length).toBe(1);
});
});
@ -532,7 +532,7 @@ describe("A frac parser", function() {
it("should produce a frac", function() {
var parse = getParsed(expression)[0];
expect(parse.type).toMatch("frac");
expect(parse.type).toEqual("genfrac");
expect(parse.value.numer).toBeDefined();
expect(parse.value.denom).toBeDefined();
});
@ -546,13 +546,13 @@ describe("A frac parser", function() {
it("should parse dfrac and tfrac as fracs", function() {
var dfracParse = getParsed(dfracExpression)[0];
expect(dfracParse.type).toMatch("frac");
expect(dfracParse.type).toEqual("genfrac");
expect(dfracParse.value.numer).toBeDefined();
expect(dfracParse.value.denom).toBeDefined();
var tfracParse = getParsed(tfracExpression)[0];
expect(tfracParse.type).toMatch("frac");
expect(tfracParse.type).toEqual("genfrac");
expect(tfracParse.value.numer).toBeDefined();
expect(tfracParse.value.denom).toBeDefined();
});
@ -572,13 +572,13 @@ describe("An over parser", function() {
parse = getParsed(simpleOver)[0];
expect(parse.type).toMatch("frac");
expect(parse.type).toEqual("genfrac");
expect(parse.value.numer).toBeDefined();
expect(parse.value.denom).toBeDefined();
parse = getParsed(complexOver)[0];
expect(parse.type).toMatch("frac");
expect(parse.type).toEqual("genfrac");
expect(parse.value.numer).toBeDefined();
expect(parse.value.denom).toBeDefined();
});
@ -600,7 +600,7 @@ describe("An over parser", function() {
it("should handle empty numerators", function () {
var emptyNumerator = "\\over x";
var parse = getParsed(emptyNumerator)[0];
expect(parse.type).toMatch("frac");
expect(parse.type).toEqual("genfrac");
expect(parse.value.numer).toBeDefined();
expect(parse.value.denom).toBeDefined();
});
@ -608,7 +608,7 @@ describe("An over parser", function() {
it("should handle empty denominators", function () {
var emptyDenominator = "1 \\over";
var parse = getParsed(emptyDenominator)[0];
expect(parse.type).toMatch("frac");
expect(parse.type).toEqual("genfrac");
expect(parse.value.numer).toBeDefined();
expect(parse.value.denom).toBeDefined();
});
@ -616,20 +616,20 @@ describe("An over parser", function() {
it("should handle \\displaystyle correctly", function () {
var displaystyleExpression = "\\displaystyle 1 \\over 2";
var parse = getParsed(displaystyleExpression)[0];
expect(parse.type).toMatch("frac");
expect(parse.value.numer.value[0].type).toMatch("styling");
expect(parse.type).toEqual("genfrac");
expect(parse.value.numer.value[0].type).toEqual("styling");
expect(parse.value.denom).toBeDefined();
});
it("should handle nested factions", function () {
var nestedOverExpression = "{1 \\over 2} \\over 3";
var parse = getParsed(nestedOverExpression)[0];
expect(parse.type).toMatch("frac");
expect(parse.value.numer.value[0].type).toMatch("frac");
expect(parse.value.numer.value[0].value.numer.value[0].value).toMatch(1);
expect(parse.value.numer.value[0].value.denom.value[0].value).toMatch(2);
expect(parse.type).toEqual("genfrac");
expect(parse.value.numer.value[0].type).toEqual("genfrac");
expect(parse.value.numer.value[0].value.numer.value[0].value).toEqual("1");
expect(parse.value.numer.value[0].value.denom.value[0].value).toEqual("2");
expect(parse.value.denom).toBeDefined();
expect(parse.value.denom.value[0].value).toMatch(3);
expect(parse.value.denom.value[0].value).toEqual("3");
});
it("should fail with multiple overs in the same group", function () {
@ -651,7 +651,7 @@ describe("A sizing parser", function() {
it("should produce a sizing node", function() {
var parse = getParsed(sizeExpression)[0];
expect(parse.type).toMatch("sizing");
expect(parse.type).toEqual("sizing");
expect(parse.value).toBeDefined();
});
});
@ -674,7 +674,7 @@ describe("A text parser", function() {
it("should produce a text", function() {
var parse = getParsed(textExpression)[0];
expect(parse.type).toMatch("text");
expect(parse.type).toEqual("text");
expect(parse.value).toBeDefined();
});
@ -682,7 +682,7 @@ describe("A text parser", function() {
var parse = getParsed(textExpression)[0];
var group = parse.value.body;
expect(group[0].type).toMatch("textord");
expect(group[0].type).toEqual("textord");
});
it("should not parse bad text", function() {
@ -705,10 +705,10 @@ describe("A text parser", function() {
var parse = getParsed(spaceTextExpression)[0];
var group = parse.value.body;
expect(group[0].type).toMatch("spacing");
expect(group[1].type).toMatch("textord");
expect(group[2].type).toMatch("spacing");
expect(group[3].type).toMatch("spacing");
expect(group[0].type).toEqual("spacing");
expect(group[1].type).toEqual("textord");
expect(group[2].type).toEqual("spacing");
expect(group[3].type).toEqual("spacing");
});
it("should accept math mode tokens after its argument", function() {
@ -738,7 +738,7 @@ describe("A color parser", function() {
it("should build a color node", function() {
var parse = getParsed(colorExpression)[0];
expect(parse.type).toMatch("color");
expect(parse.type).toEqual("color");
expect(parse.value.color).toBeDefined();
expect(parse.value.value).toBeDefined();
});
@ -750,7 +750,7 @@ describe("A color parser", function() {
it("should correctly extract the custom color", function() {
var parse = getParsed(customColorExpression)[0];
expect(parse.value.color).toMatch("#fA6");
expect(parse.value.color).toEqual("#fA6");
});
it("should not parse a bad custom color", function() {
@ -784,21 +784,21 @@ describe("A tie parser", function() {
it("should produce spacing in math mode", function() {
var parse = getParsed(mathTie);
expect(parse[1].type).toMatch("spacing");
expect(parse[1].type).toEqual("spacing");
});
it("should produce spacing in text mode", function() {
var text = getParsed(textTie)[0];
var parse = text.value.body;
expect(parse[1].type).toMatch("spacing");
expect(parse[1].type).toEqual("spacing");
});
it("should not contract with spaces in text mode", function() {
var text = getParsed(textTie)[0];
var parse = text.value.body;
expect(parse[2].type).toMatch("spacing");
expect(parse[2].type).toEqual("spacing");
});
});
@ -819,15 +819,15 @@ describe("A delimiter sizing parser", function() {
it("should produce a delimsizing", function() {
var parse = getParsed(normalDelim)[0];
expect(parse.type).toMatch("delimsizing");
expect(parse.type).toEqual("delimsizing");
});
it("should produce the correct direction delimiter", function() {
var leftParse = getParsed(normalDelim)[0];
var rightParse = getParsed(bigDelim)[0];
expect(leftParse.value.delimType).toMatch("open");
expect(rightParse.value.delimType).toMatch("close");
expect(leftParse.value.delimType).toEqual("open");
expect(rightParse.value.delimType).toEqual("close");
});
it("should parse the correct size delimiter", function() {
@ -849,7 +849,7 @@ describe("An overline parser", function() {
it("should produce an overline", function() {
var parse = getParsed(overline)[0];
expect(parse.type).toMatch("overline");
expect(parse.type).toEqual("overline");
});
});
@ -879,18 +879,18 @@ describe("A rule parser", function() {
it("should produce a rule", function() {
var parse = getParsed(emRule)[0];
expect(parse.type).toMatch("rule");
expect(parse.type).toEqual("rule");
});
it("should list the correct units", function() {
var emParse = getParsed(emRule)[0];
var exParse = getParsed(exRule)[0];
expect(emParse.value.width.unit).toMatch("em");
expect(emParse.value.height.unit).toMatch("em");
expect(emParse.value.width.unit).toEqual("em");
expect(emParse.value.height.unit).toEqual("em");
expect(exParse.value.width.unit).toMatch("ex");
expect(exParse.value.height.unit).toMatch("em");
expect(exParse.value.width.unit).toEqual("ex");
expect(exParse.value.height.unit).toEqual("em");
});
it("should parse the number correctly", function() {
@ -919,9 +919,9 @@ describe("A left/right parser", function() {
it("should produce a leftright", function() {
var parse = getParsed(normalLeftRight)[0];
expect(parse.type).toMatch("leftright");
expect(parse.value.left).toMatch("\\(");
expect(parse.value.right).toMatch("\\)");
expect(parse.type).toEqual("leftright");
expect(parse.value.left).toEqual("(");
expect(parse.value.right).toEqual(")");
});
it("should error when it is mismatched", function() {
@ -1009,7 +1009,7 @@ describe("A sqrt parser", function() {
it("should produce sqrts", function() {
var parse = getParsed(sqrt)[0];
expect(parse.type).toMatch("sqrt");
expect(parse.type).toEqual("sqrt");
});
});
@ -1168,10 +1168,10 @@ describe("A style change parser", function() {
it("should produce the correct style", function() {
var displayParse = getParsed("\\displaystyle x")[0];
expect(displayParse.value.style).toMatch("display");
expect(displayParse.value.style).toEqual("display");
var scriptscriptParse = getParsed("\\scriptscriptstyle x")[0];
expect(scriptscriptParse.value.style).toMatch("scriptscript");
expect(scriptscriptParse.value.style).toEqual("scriptscript");
});
it("should only change the style within its group", function() {
@ -1180,12 +1180,12 @@ describe("A style change parser", function() {
var displayNode = parse[2].value[2];
expect(displayNode.type).toMatch("styling");
expect(displayNode.type).toEqual("styling");
var displayBody = displayNode.value.value;
expect(displayBody.length).toEqual(2);
expect(displayBody[0].value).toMatch("e");
expect(displayBody[0].value).toEqual("e");
});
});
@ -1206,48 +1206,48 @@ describe("A font parser", function () {
it("should produce the correct fonts", function () {
var mathbbParse = getParsed("\\mathbb x")[0];
expect(mathbbParse.value.font).toMatch("mathbb");
expect(mathbbParse.value.type).toMatch("font");
expect(mathbbParse.value.font).toEqual("mathbb");
expect(mathbbParse.value.type).toEqual("font");
var mathrmParse = getParsed("\\mathrm x")[0];
expect(mathrmParse.value.font).toMatch("mathrm");
expect(mathrmParse.value.type).toMatch("font");
expect(mathrmParse.value.font).toEqual("mathrm");
expect(mathrmParse.value.type).toEqual("font");
var mathitParse = getParsed("\\mathit x")[0];
expect(mathitParse.value.font).toMatch("mathit");
expect(mathitParse.value.type).toMatch("font");
expect(mathitParse.value.font).toEqual("mathit");
expect(mathitParse.value.type).toEqual("font");
var mathcalParse = getParsed("\\mathcal C")[0];
expect(mathcalParse.value.font).toMatch("mathcal");
expect(mathcalParse.value.type).toMatch("font");
expect(mathcalParse.value.font).toEqual("mathcal");
expect(mathcalParse.value.type).toEqual("font");
var mathfrakParse = getParsed("\\mathfrak C")[0];
expect(mathfrakParse.value.font).toMatch("mathfrak");
expect(mathfrakParse.value.type).toMatch("font");
expect(mathfrakParse.value.font).toEqual("mathfrak");
expect(mathfrakParse.value.type).toEqual("font");
});
it("should parse nested font commands", function () {
var nestedParse = getParsed("\\mathbb{R \\neq \\mathrm{R}}")[0];
expect(nestedParse.value.font).toMatch("mathbb");
expect(nestedParse.value.type).toMatch("font");
expect(nestedParse.value.font).toEqual("mathbb");
expect(nestedParse.value.type).toEqual("font");
expect(nestedParse.value.body.value.length).toMatch(3);
expect(nestedParse.value.body.value.length).toEqual(3);
var bbBody = nestedParse.value.body.value;
expect(bbBody[0].type).toMatch("mathord");
expect(bbBody[1].type).toMatch("rel");
expect(bbBody[2].type).toMatch("font");
expect(bbBody[2].value.font).toMatch("mathrm");
expect(bbBody[2].value.type).toMatch("font");
expect(bbBody[0].type).toEqual("mathord");
expect(bbBody[1].type).toEqual("rel");
expect(bbBody[2].type).toEqual("font");
expect(bbBody[2].value.font).toEqual("mathrm");
expect(bbBody[2].value.type).toEqual("font");
});
it("should work with \\color", function () {
var colorMathbbParse = getParsed("\\color{blue}{\\mathbb R}")[0];
expect(colorMathbbParse.value.type).toMatch("color");
expect(colorMathbbParse.value.color).toMatch("blue");
expect(colorMathbbParse.value.type).toEqual("color");
expect(colorMathbbParse.value.color).toEqual("blue");
var body = colorMathbbParse.value.value;
expect(body.length).toMatch(1);
expect(body[0].value.type).toMatch("font");
expect(body[0].value.font).toMatch("mathbb");
expect(body.length).toEqual(1);
expect(body[0].value.type).toEqual("font");
expect(body[0].value.font).toEqual("mathbb");
});
it("should not parse a series of font commands", function () {
@ -1256,13 +1256,13 @@ describe("A font parser", function () {
it("should nest fonts correctly", function () {
var bf = getParsed("\\mathbf{a\\mathrm{b}c}")[0];
expect(bf.value.type).toMatch("font");
expect(bf.value.font).toMatch("mathbf");
expect(bf.value.body.value.length).toMatch(3);
expect(bf.value.body.value[0].value).toMatch("a");
expect(bf.value.body.value[1].value.type).toMatch("font");
expect(bf.value.body.value[1].value.font).toMatch("mathrm");
expect(bf.value.body.value[2].value).toMatch("c");
expect(bf.value.type).toEqual("font");
expect(bf.value.font).toEqual("mathbf");
expect(bf.value.body.value.length).toEqual(3);
expect(bf.value.body.value[0].value).toEqual("a");
expect(bf.value.body.value[1].value.type).toEqual("font");
expect(bf.value.body.value[1].value.font).toEqual("mathrm");
expect(bf.value.body.value[2].value).toEqual("c");
});
it("should have the correct greediness", function() {
@ -1530,13 +1530,13 @@ describe("An accent parser", function() {
it("should produce accents", function() {
var parse = getParsed("\\vec x")[0];
expect(parse.type).toMatch("accent");
expect(parse.type).toEqual("accent");
});
it("should be grouped more tightly than supsubs", function() {
var parse = getParsed("\\vec x^2")[0];
expect(parse.type).toMatch("supsub");
expect(parse.type).toEqual("supsub");
});
it("should not parse expanding accents", function() {
@ -1572,7 +1572,7 @@ describe("A phantom parser", function() {
it("should build a phantom node", function() {
var parse = getParsed("\\phantom{x}")[0];
expect(parse.type).toMatch("phantom");
expect(parse.type).toEqual("phantom");
expect(parse.value.value).toBeDefined();
});
});