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 (
<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}/>
<Epochs epochs={epochs} setEpochs={setEpochs} errors={errors}/>
<Options options={options} setOptions={setOptions} runChanges={runChanges}/>

View file

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

View file

@ -3,7 +3,7 @@ import ReactDOM from 'react-dom';
import ProtoLang from './ProtoLang';
import renderer from 'react-test-renderer';
import { exportAllDeclaration } from '@babel/types';
import {render} from '@testing-library/react';
import { render } from '@testing-library/react';
import extendExpect from '@testing-library/jest-dom/extend-expect'
it('renders ProtoLang without crashing', () => {
@ -21,7 +21,11 @@ describe('ProtoLang', () => {
})
it('renders lexicon from state', () => {
const { getByTestId } = render(<ProtoLang lexicon={['one']}/>);
expect(getByTestId('ProtoLang-Lexicon')).toHaveFormValues({lexicon: 'one'});
const { getByTestId } = render(<ProtoLang lexicon={[{ lexeme:'one', epoch:{name: 'epoch-one', changes: []} }]}/>);
expect(getByTestId('ProtoLang-Lexicon')).toHaveFormValues({lexicon: 'one #epoch-one'});
})
it('', () => {
})
})