mirror of
https://github.com/keymanapp/keyman.git
synced 2026-10-27 08:17:52 +00:00
Fixes #7235. Encapsulates all strings in the in-memory compile so that we can binary sort them for build. This means that finalization of strs and elem is no longer needed -- it's part of setup of build_strs and build_elem -- so that is factored away. Renamed alloc_string and alloc_element_string. It may be worth renaming some of the ELEM_STRING objects / interfaces as currently they are a little confusing.
35 lines
1.3 KiB
TypeScript
35 lines
1.3 KiB
TypeScript
import 'mocha';
|
|
import { assert } from 'chai';
|
|
import { NameCompiler } from '../src/keyman/compiler/name';
|
|
import { CompilerCallbacks, loadSectionFixture } from './helpers';
|
|
import { Name } from '../src/keyman/kmx/kmx-plus';
|
|
//import { CompilerMessages } from './keyman/compiler/messages';
|
|
|
|
describe('name', function () {
|
|
this.slow(500); // 0.5 sec -- json schema validation takes a while
|
|
|
|
it('should compile minimal name data', function() {
|
|
const callbacks = new CompilerCallbacks();
|
|
let name = loadSectionFixture(NameCompiler, 'sections/name/minimal.xml', callbacks) as Name;
|
|
assert.equal(callbacks.messages.length, 0);
|
|
|
|
assert.equal(name.names.length, 1);
|
|
assert.equal(name.names[0].value, 'My First Keyboard');
|
|
});
|
|
|
|
it('should compile multiple names', function() {
|
|
const callbacks = new CompilerCallbacks();
|
|
let name = loadSectionFixture(NameCompiler, 'sections/name/multiple.xml', callbacks) as Name;
|
|
assert.equal(callbacks.messages.length, 0);
|
|
|
|
assert.equal(name.names.length, 5);
|
|
assert.equal(name.names[0].value, 'My Second Keyboard');
|
|
assert.equal(name.names[1].value, 'My 2nd Keyboard');
|
|
assert.equal(name.names[2].value, 'win:kbd2');
|
|
assert.equal(name.names[3].value, 'mac:keybd_2');
|
|
assert.equal(name.names[4].value, 'web:keyboard-2');
|
|
});
|
|
|
|
//TODO-LDML: should we be linting on repeated names?
|
|
});
|
|
|