mirror of
https://github.com/keymanapp/keyman.git
synced 2026-08-11 19:35:32 +00:00
feat(developer): add unit tests for 'name' compiler
This commit is contained in:
parent
b2b62733e6
commit
c08dbfbf9f
3 changed files with 60 additions and 0 deletions
10
developer/src/kmldmlc/test/fixtures/sections/name/minimal.xml
vendored
Normal file
10
developer/src/kmldmlc/test/fixtures/sections/name/minimal.xml
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!DOCTYPE keyboard SYSTEM "../../../../../../../resources/standards-data/ldml-keyboards/techpreview/ldmlKeyboard.dtd">
|
||||
<keyboard locale="mt" conformsTo="techpreview">
|
||||
<names>
|
||||
<name value="My First Keyboard" />
|
||||
</names>
|
||||
|
||||
<keys />
|
||||
</keyboard>
|
||||
15
developer/src/kmldmlc/test/fixtures/sections/name/multiple.xml
vendored
Normal file
15
developer/src/kmldmlc/test/fixtures/sections/name/multiple.xml
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!DOCTYPE keyboard SYSTEM "../../../../../../../resources/standards-data/ldml-keyboards/techpreview/ldmlKeyboard.dtd">
|
||||
<keyboard locale="mt" conformsTo="techpreview">
|
||||
<names>
|
||||
<name value="My Second Keyboard" />
|
||||
<name value="My 2nd Keyboard" />
|
||||
<!-- so these following names are really just a made up idea of how multiple names *could* be used -->
|
||||
<name value="win:kbd2" />
|
||||
<name value="mac:keybd_2" />
|
||||
<name value="web:keyboard-2" />
|
||||
</names>
|
||||
|
||||
<keys />
|
||||
</keyboard>
|
||||
35
developer/src/kmldmlc/test/test-name.ts
Normal file
35
developer/src/kmldmlc/test/test-name.ts
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
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], '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], 'My Second Keyboard');
|
||||
assert.equal(name.names[1], 'My 2nd Keyboard');
|
||||
assert.equal(name.names[2], 'win:kbd2');
|
||||
assert.equal(name.names[3], 'mac:keybd_2');
|
||||
assert.equal(name.names[4], 'web:keyboard-2');
|
||||
});
|
||||
|
||||
//TODO-LDML: should we be linting on repeated names?
|
||||
});
|
||||
|
||||
Loading…
Add table
Reference in a new issue