diff --git a/developer/src/kmldmlc/test/fixtures/sections/name/minimal.xml b/developer/src/kmldmlc/test/fixtures/sections/name/minimal.xml new file mode 100644 index 0000000000..da730b6a46 --- /dev/null +++ b/developer/src/kmldmlc/test/fixtures/sections/name/minimal.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/developer/src/kmldmlc/test/fixtures/sections/name/multiple.xml b/developer/src/kmldmlc/test/fixtures/sections/name/multiple.xml new file mode 100644 index 0000000000..39bf9ff309 --- /dev/null +++ b/developer/src/kmldmlc/test/fixtures/sections/name/multiple.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/developer/src/kmldmlc/test/test-name.ts b/developer/src/kmldmlc/test/test-name.ts new file mode 100644 index 0000000000..65d5729975 --- /dev/null +++ b/developer/src/kmldmlc/test/test-name.ts @@ -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? +}); +