Files
KaTeX/test/unicode-spec.js
Ryan Randall fbffdc5fc7 Webpack dev server (#902)
* Initial webpack config. Moving to ES6 modules. Some module cleanup.

* WIP

* WIP

* Removing commented out code.

* Removing old deps.

* Removing the build script (used for testing).

* Working tests.

* Switching to node api over cli.

* Updating per comments. Still need to fix server.js to properly run the selenium tests.

* Cleaning up the config.

* More cleanup.

* Bringing back server.js for selenium tests.

* Bringing back old dependencies.

* Adding back eslint rules for webpack config. Final cleanup for webpack config.

* Pointing to correct pre-existing module versions. Adding some extra logic to server.js to ensure it gets transpiled properly.

* Getting make build to work again. Updating package.json with some shortcut scripts.

* Resolving conflict.

* Reverting back to commonjs modules.

* Removing extra spaces in babelrc
2017-09-26 12:16:35 -06:00

95 lines
3.0 KiB
JavaScript

/* eslint max-len:0 */
/* global beforeEach: false */
/* global expect: false */
/* global it: false */
/* global describe: false */
import ParseError from "../src/ParseError";
import parseTree from "../src/parseTree";
import Settings from "../src/Settings";
const defaultSettings = new Settings({});
const parseAndSetResult = function(expr, result, settings) {
try {
return parseTree(expr, settings || defaultSettings);
} catch (e) {
result.pass = false;
if (e instanceof ParseError) {
result.message = "'" + expr + "' failed " +
"parsing with error: " + e.message;
} else {
result.message = "'" + expr + "' failed " +
"parsing with unknown error: " + e.message;
}
}
};
describe("unicode", function() {
beforeEach(function() {
expect.extend({
toParse: function(actual, settings) {
const usedSettings = settings ? settings : defaultSettings;
const result = {
pass: true,
message: "'" + actual + "' succeeded parsing",
};
parseAndSetResult(actual, result, usedSettings);
return result;
},
toNotParse: function(actual, settings) {
const usedSettings = settings ? settings : defaultSettings;
const result = {
pass: false,
message: "Expected '" + actual + "' to fail " +
"parsing, but it succeeded",
};
try {
parseTree(actual, usedSettings);
} catch (e) {
if (e instanceof ParseError) {
result.pass = true;
result.message = "'" + actual + "' correctly " +
"didn't parse with error: " + e.message;
} else {
result.message = "'" + actual + "' failed " +
"parsing with unknown error: " + e.message;
}
}
return result;
},
});
});
it("should parse Latin-1 inside \\text{}", function() {
expect('\\text{ÀàÇçÉéÏïÖöÛû}').toParse();
});
it("should parse Latin-1 outside \\text{}", function() {
expect('ÀàÇçÉéÏïÖöÛû').toParse();
});
it("should parse Cyrillic inside \\text{}", function() {
expect('\\text{БГДЖЗЙЛФЦШЫЮЯ}').toParse();
});
it("should not parse Cyrillic outside \\text{}", function() {
expect('БГДЖЗЙЛФЦШЫЮЯ').toNotParse();
});
it("should parse CJK inside \\text{}", function() {
expect('\\text{私はバナナです}').toParse();
expect('\\text{여보세요}').toParse();
});
it("should not parse CJK outside \\text{}", function() {
expect('私はバナナです。').toNotParse();
expect('여보세요').toNotParse();
});
});