mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-22 20:24:18 -04:00
(test) add tests for merging pronoun groups by key
This commit is contained in:
parent
541013a558
commit
c7735a522c
@ -9,69 +9,7 @@ jest.unstable_mockModule('../data/pronouns/morphemes.js', () => {
|
||||
|
||||
const { Pronoun } = await import('../src/classes.js');
|
||||
const { buildPronoun } = await import('../src/buildPronoun.js');
|
||||
|
||||
const pronouns = {
|
||||
he: new Pronoun(
|
||||
'he',
|
||||
'Normative “he/him”',
|
||||
true,
|
||||
{
|
||||
pronoun_subject: 'he',
|
||||
pronoun_object: 'him',
|
||||
possessive_determiner: 'his',
|
||||
possessive_pronoun: 'his',
|
||||
reflexive: 'himself',
|
||||
},
|
||||
[false],
|
||||
[false],
|
||||
['he/him'],
|
||||
'',
|
||||
true,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
),
|
||||
she: new Pronoun(
|
||||
'she',
|
||||
'Normative “she/her”',
|
||||
true,
|
||||
{
|
||||
pronoun_subject: 'she',
|
||||
pronoun_object: 'her',
|
||||
possessive_determiner: 'her',
|
||||
possessive_pronoun: 'hers',
|
||||
reflexive: 'herself',
|
||||
},
|
||||
[false],
|
||||
[false],
|
||||
['she/her'],
|
||||
'',
|
||||
true,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
),
|
||||
they: new Pronoun(
|
||||
'they',
|
||||
'Singular “they”',
|
||||
true,
|
||||
{
|
||||
pronoun_subject: 'they',
|
||||
pronoun_object: 'them',
|
||||
possessive_determiner: 'their',
|
||||
possessive_pronoun: 'theirs',
|
||||
reflexive: 'themselves',
|
||||
},
|
||||
[true],
|
||||
[true],
|
||||
['they/them'],
|
||||
'',
|
||||
true,
|
||||
'',
|
||||
'themselves',
|
||||
'',
|
||||
),
|
||||
};
|
||||
const { default: pronouns } = await import('./fixtures/pronouns.js');
|
||||
|
||||
beforeEach(() => {
|
||||
global.config.pronouns = {
|
||||
|
61
test/classes.test.js
Normal file
61
test/classes.test.js
Normal file
@ -0,0 +1,61 @@
|
||||
import { describe, expect, test } from '@jest/globals';
|
||||
|
||||
import { PronounGroup, PronounLibrary } from '../src/classes.js';
|
||||
|
||||
import pronouns from './fixtures/pronouns.js';
|
||||
|
||||
describe('when merging pronoun groups by key', () => {
|
||||
test('groups without keys are not assigned a merged group', () => {
|
||||
const groups = [
|
||||
new PronounGroup('Normative-ish forms', ['they']),
|
||||
];
|
||||
const library = new PronounLibrary(groups, pronouns);
|
||||
expect(library.byKey()).toEqual({});
|
||||
});
|
||||
|
||||
test('groups with different keys are assigned different merged groups', () => {
|
||||
const groups = [
|
||||
new PronounGroup('Binary forms', ['he', 'she'], null, 'normative'),
|
||||
new PronounGroup('Normative-ish forms', ['they'], null, 'normative-ish'),
|
||||
];
|
||||
const library = new PronounLibrary(groups, pronouns);
|
||||
expect(library.byKey()).toEqual(
|
||||
{
|
||||
'normative': [
|
||||
{
|
||||
group: groups[0],
|
||||
groupPronouns: { he: pronouns.he, she: pronouns.she },
|
||||
},
|
||||
],
|
||||
'normative-ish': [
|
||||
{
|
||||
group: groups[1],
|
||||
groupPronouns: { they: pronouns.they },
|
||||
},
|
||||
],
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
test('groups with same key are assigned same merged group', () => {
|
||||
const groups = [
|
||||
new PronounGroup('Binary forms', ['he', 'she'], null, 'normative-ish'),
|
||||
new PronounGroup('Normative-ish forms', ['they'], null, 'normative-ish'),
|
||||
];
|
||||
const library = new PronounLibrary(groups, pronouns);
|
||||
expect(library.byKey()).toEqual(
|
||||
{
|
||||
'normative-ish': [
|
||||
{
|
||||
group: groups[0],
|
||||
groupPronouns: { he: pronouns.he, she: pronouns.she },
|
||||
},
|
||||
{
|
||||
group: groups[1],
|
||||
groupPronouns: { they: pronouns.they },
|
||||
},
|
||||
],
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
70
test/fixtures/pronouns.js
vendored
Normal file
70
test/fixtures/pronouns.js
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
import { Pronoun } from '../../src/classes.js';
|
||||
|
||||
const he = new Pronoun(
|
||||
'he',
|
||||
'Normative “he/him”',
|
||||
true,
|
||||
{
|
||||
pronoun_subject: 'he',
|
||||
pronoun_object: 'him',
|
||||
possessive_determiner: 'his',
|
||||
possessive_pronoun: 'his',
|
||||
reflexive: 'himself',
|
||||
},
|
||||
[false],
|
||||
[false],
|
||||
['he/him'],
|
||||
'',
|
||||
true,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
);
|
||||
|
||||
const she = new Pronoun(
|
||||
'she',
|
||||
'Normative “she/her”',
|
||||
true,
|
||||
{
|
||||
pronoun_subject: 'she',
|
||||
pronoun_object: 'her',
|
||||
possessive_determiner: 'her',
|
||||
possessive_pronoun: 'hers',
|
||||
reflexive: 'herself',
|
||||
},
|
||||
[false],
|
||||
[false],
|
||||
['she/her'],
|
||||
'',
|
||||
true,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
);
|
||||
|
||||
const they = new Pronoun(
|
||||
'they',
|
||||
'Singular “they”',
|
||||
true,
|
||||
{
|
||||
pronoun_subject: 'they',
|
||||
pronoun_object: 'them',
|
||||
possessive_determiner: 'their',
|
||||
possessive_pronoun: 'theirs',
|
||||
reflexive: 'themselves',
|
||||
},
|
||||
[true],
|
||||
[true],
|
||||
['they/them'],
|
||||
'',
|
||||
true,
|
||||
'',
|
||||
'themselves',
|
||||
'',
|
||||
);
|
||||
|
||||
export default {
|
||||
he,
|
||||
she,
|
||||
they,
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user