From 9a8563ebd762aa3aef50d91b69033e6865e24cf7 Mon Sep 17 00:00:00 2001 From: Sorrel Bri Date: Wed, 18 Dec 2019 15:51:41 -0800 Subject: [PATCH] fix Features test, clear Features cruft --- src/components/Features.js | 33 --------------------------------- src/components/Features.test.js | 15 ++++++++++----- 2 files changed, 10 insertions(+), 38 deletions(-) diff --git a/src/components/Features.js b/src/components/Features.js index 637ffc5..5c6d661 100644 --- a/src/components/Features.js +++ b/src/components/Features.js @@ -29,39 +29,6 @@ const parsePhonesFromFeatureObject = featureObject => { } const featureMap = getFeatureMap(featureObject); - console.log(featureMap) - const featureMapJSX = getFeatureMapJSX(featureMap); - return featureMapJSX; -} - -const parseFeaturesFromPhonemeObject = phonesObject => { - - const getFeatureMap = (phonesObject) => { - return Object.keys(phonesObject).reduce((featureObject, phoneName) => { - let phone = phonesObject[phoneName]; - Object.keys(phone.features).forEach(feature => { - if (!featureObject[feature]) featureObject[feature] = {plus: [], minus: []} - if (phone.features[feature]) featureObject[feature].plus.push(phone.grapheme) - else featureObject[feature].minus.push(phone.grapheme) - }); - return featureObject; - }, {}) - } - - const getFeatureMapJSX = (featureMap) => { - return Object.keys(featureMap).map(feature => { - const plusPhones = featureMap[feature].plus.join('|'); - const minusPhones = featureMap[feature].minus.join('|'); - return ( -
  • - {`[+ ${feature}] = ${plusPhones}`} - {`[- ${feature}] = ${minusPhones}`} -
  • - ) - }); - } - - const featureMap = getFeatureMap(phonesObject); const featureMapJSX = getFeatureMapJSX(featureMap); return featureMapJSX; } diff --git a/src/components/Features.test.js b/src/components/Features.test.js index 0ae997a..d1b2e31 100644 --- a/src/components/Features.test.js +++ b/src/components/Features.test.js @@ -20,11 +20,16 @@ describe('Features', () => { }); it('renders features from phonemes hook', () => { - const { getByTestId } = render(); + const nPhone = {n:{ + grapheme: 'n', + features: { nasal: true, occlusive: true, vowel: false } }} + const { getByTestId } = render(); expect(getByTestId('Features-list')) .toContainHTML('
    • [+ nasal] = n[- nasal] =
    • [+ occlusive] = n[- occlusive] =
    • [+ vowel] = [- vowel] = n
    ');