hook lexicon into ProtoLang render

This commit is contained in:
Sorrel Bri 2019-12-16 14:52:38 -08:00
parent cabf342b4a
commit 7de78839b0
3 changed files with 10 additions and 6 deletions

View file

@ -122,7 +122,7 @@ const PhonoChangeApplier = () => {
return ( return (
<div className="PhonoChangeApplier" data-testid="PhonoChangeApplier"> <div className="PhonoChangeApplier" data-testid="PhonoChangeApplier">
<ProtoLang lexicon={lexicon} setLexicon={setLexicon}/> <ProtoLang lexicon={state.lexicon} dispatch={dispatch}/>
<Features phonemes={phonemes} setPhonemes={setPhonemes} features={features} setFeatures={setFeatures}/> <Features phonemes={phonemes} setPhonemes={setPhonemes} features={features} setFeatures={setFeatures}/>
<Epochs epochs={epochs} setEpochs={setEpochs} errors={errors}/> <Epochs epochs={epochs} setEpochs={setEpochs} errors={errors}/>
<Options options={options} setOptions={setOptions} runChanges={runChanges}/> <Options options={options} setOptions={setOptions} runChanges={runChanges}/>

View file

@ -9,8 +9,8 @@ const ProtoLang = (props) => {
<form data-testid="ProtoLang-Lexicon"> <form data-testid="ProtoLang-Lexicon">
<textarea <textarea
name="lexicon" name="lexicon"
value={props.lexicon ? props.lexicon.join("\n") : ''} value={props.lexicon ? props.lexicon.map(lexeme => `${lexeme.lexeme} \t#${lexeme.epoch.name}`).join('\n'): ''}
onChange={e=>props.setLexicon(e.target.value.split(/\n/))} onChange={e=>props.dispatch({action: 'SET_LEXION', value: e.target.value.split(/\n/)})}
> >
</textarea> </textarea>
</form> </form>

View file

@ -21,7 +21,11 @@ describe('ProtoLang', () => {
}) })
it('renders lexicon from state', () => { it('renders lexicon from state', () => {
const { getByTestId } = render(<ProtoLang lexicon={['one']}/>); const { getByTestId } = render(<ProtoLang lexicon={[{ lexeme:'one', epoch:{name: 'epoch-one', changes: []} }]}/>);
expect(getByTestId('ProtoLang-Lexicon')).toHaveFormValues({lexicon: 'one'}); expect(getByTestId('ProtoLang-Lexicon')).toHaveFormValues({lexicon: 'one #epoch-one'});
})
it('', () => {
}) })
}) })