Skip to content

Commit

Permalink
Merge pull request #12 from translationCoreApps/fix-richmahn-memory-l…
Browse files Browse the repository at this point in the history
…eak-fix

Fix - no longer translating in the helper function
  • Loading branch information
mannycolon authored Nov 14, 2018
2 parents 991ec4a + 2ce1a9b commit 700eb96
Show file tree
Hide file tree
Showing 5 changed files with 1,524 additions and 1,528 deletions.
48 changes: 24 additions & 24 deletions __tests__/MorphUtils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,48 @@ import path from 'path-extra';
import * as MorphUtils from '../src/js/utils/MorphUtils';

describe('MorphUtils tests', () => {
it('Test MorphUtils.getFullMorphologicalString() - All morph strings render as expected', () => {
it('Test MorphUtils.getMorphLocalizationKeys() - All morph strings render as expected', () => {
const morphsPath = path.join('__tests__', 'fixtures', 'morphs', 'all-titus-morphs.json');
const allTitusMorphs = fs.readJSONSync(morphsPath);
Object.keys(allTitusMorphs).forEach(morph => {
const morphStr = MorphUtils.getFullMorphologicalString(morph);
// process.stdout.write(' "'+morph+'": "'+morphStr+'",\n');
expect(morphStr).toEqual(allTitusMorphs[morph]);
const morphKeys = MorphUtils.getMorphLocalizationKeys(morph);
// process.stdout.write(' "'+morph+'": "'+morphKeys+'",\n');
expect(morphKeys).toEqual(allTitusMorphs[morph]);
});
});

it('Test MorphUtils.getFullMorphologicalString() - Unknown codes still return in comma delimited list', () => {
it('Test MorphUtils.getMorphLocalizationKeys() - Unknown codes still return in comma delimited list', () => {
const badMorph = 'AbCZEF,HI';
const expectedMorphStr = 'Z, E, F, H, I';
const morphStr = MorphUtils.getFullMorphologicalString(badMorph);
expect(morphStr).toEqual(expectedMorphStr);
const expectedMorphKeys = ['*Z', '*E', '*F', '*H', '*I'];
const morphKeys = MorphUtils.getMorphLocalizationKeys(badMorph);
expect(morphKeys).toEqual(expectedMorphKeys);
});

it('Test MorphUtils.getFullMorphologicalString() - morph is null', () => {
it('Test MorphUtils.getMorphLocalizationKeys() - morph is null', () => {
const badMorph = null;
const expectedMorphStr = '';
const morphStr = MorphUtils.getFullMorphologicalString(badMorph);
expect(morphStr).toEqual(expectedMorphStr);
const expectedMorphKeys = [];
const morphKeys = MorphUtils.getMorphLocalizationKeys(badMorph);
expect(morphKeys).toEqual(expectedMorphKeys);
});

it('Test MorphUtils.getFullMorphologicalString() - morph is too short', () => {
it('Test MorphUtils.getMorphLocalizationKeys() - morph is too short', () => {
const badMorph = 'Gr,';
const expectedMorphStr = 'Gr,';
const morphStr = MorphUtils.getFullMorphologicalString(badMorph);
expect(morphStr).toEqual(expectedMorphStr);
const expectedMorphKeys = 'Gr,';
const morphKeys = MorphUtils.getMorphLocalizationKeys(badMorph);
expect(morphKeys).toEqual(expectedMorphKeys);
});

it('Test MorphUtils.getFullMorphologicalString() - morph is just a role', () => {
it('Test MorphUtils.getMorphLocalizationKeys() - morph is just a role', () => {
const badMorph = 'Gr,A';
const expectedMorphStr = 'adjective';
const morphStr = MorphUtils.getFullMorphologicalString(badMorph);
expect(morphStr).toEqual(expectedMorphStr);
const expectedMorphKeys = ['adjective'];
const morphKeys = MorphUtils.getMorphLocalizationKeys(badMorph);
expect(morphKeys).toEqual(expectedMorphKeys);
});

it('Test MorphUtils.getFullMorphologicalString() - morph is not a string', () => {
it('Test MorphUtils.getMorphLocalizationKeys() - morph is not a string', () => {
const badMorph = {A: 'B'};
const expectedMorphStr = '';
const morphStr = MorphUtils.getFullMorphologicalString(badMorph);
expect(morphStr).toEqual(expectedMorphStr);
const expectedMorphKeys = [];
const morphKeys = MorphUtils.getMorphLocalizationKeys(badMorph);
expect(morphKeys).toEqual(expectedMorphKeys);
});
});
Loading

0 comments on commit 700eb96

Please sign in to comment.