mathjs/test/utils/latex.test.js
2018-10-31 21:18:51 +01:00

23 lines
656 B
JavaScript

import assert from 'assert'
import { toSymbol } from '../../src/utils/latex'
describe('util.latex', function () {
it('should convert symbols with underscores', function () {
assert.strictEqual(toSymbol('alpha_1'), 'alpha\\_1')
})
it('should convert special units', function () {
assert.strictEqual(toSymbol('deg', true), '^\\circ')
})
it('should convert normal units', function () {
assert.strictEqual(toSymbol('cm', true), '\\mathrm{cm}')
})
it('should escape strings', function () {
const string = 'space tab\tunderscore_bla$/'
assert.strictEqual(toSymbol(string), 'space~tab\\qquad{}underscore\\_bla\\$/')
})
})