diff --git a/src/buildPronoun.js b/src/buildPronoun.js index b88509c00..8d3b96b26 100644 --- a/src/buildPronoun.js +++ b/src/buildPronoun.js @@ -44,10 +44,8 @@ const buildPronounFromTemplate = (key, template) => { template.description, template.normative || false, buildDict(function*(morphemes) { - for (const k in morphemes) { - if (morphemes.hasOwnProperty(k)) { - yield [k, buildMorphemeFromTemplate(key, morphemes[k])]; - } + for (const m of MORPHEMES) { + yield [m, Object.hasOwn(morphemes, m) ? buildMorphemeFromTemplate(key, morphemes[m]) : null]; } }, template.morphemes), [template.plural || false], diff --git a/test/buildPronoun.test.js b/test/buildPronoun.test.js index c8f2b435a..de91da927 100644 --- a/test/buildPronoun.test.js +++ b/test/buildPronoun.test.js @@ -130,6 +130,40 @@ describe('when configured that null pronouns are available', () => { expect(buildPronoun(pronouns, `:${name}`, translator).morphemes.possessive_pronoun).toBe(`${name}s`); }); }); + + describe('when some morphemes are not defined in template', () => { + beforeEach(() => { + global.config.pronouns.null = { + morphemes: { + pronoun_subject: '#', + pronoun_object: '#', + possessive_determiner: '#\'s', + possessive_pronoun: '#\'s', + }, + }; + }); + test('they become null', () => { + const actual = expect(buildPronoun(pronouns, ':S', translator)); + actual.toBeDefined(); + actual.toEqual(new Pronoun( + 'S', + '', + false, + { + pronoun_subject: 'S', + pronoun_object: 'S', + possessive_determiner: 'S\'s', + possessive_pronoun: 'S\'s', + reflexive: null, + }, + [false], + [false], + [], + '__generator__', + false, + )); + }); + }); }); describe('when configured that slashes contain all morphemes', () => {