mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-18 14:59:29 +00:00
23 lines
659 B
JavaScript
23 lines
659 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\\$/')
|
|
})
|
|
})
|