display results of run in Output component

This commit is contained in:
Sorrel Bri 2020-02-16 18:28:43 -08:00
parent 3d0bde1c55
commit a19102f82e
6 changed files with 36 additions and 19 deletions

View file

@ -82,8 +82,8 @@ const PhonoChangeApplier = () => {
}
startingIndex = index;
})
lexemeBundle.unshift(['#'])
lexemeBundle.push(['#'])
// lexemeBundle.unshift(['#'])
// lexemeBundle.push(['#'])
lexicalFeatureBundles.push(lexemeBundle);
})
console.log(lexicalFeatureBundles)

View file

@ -2,12 +2,13 @@ import React from 'react';
import './Output.scss';
const Output = props => {
const { results } = props;
return (
<div className="Output" data-testid="Output">
<h3>Results of Run</h3>
<div data-testid="Output-lexicon">
{props.results ? props.results.map((lexicalItem, i) => <p key={`output-lexical-item-${i}`}>{lexicalItem}</p>) : <></>}
{results && results.length ? results[0].lexicon.map((lexicalItem, i) => <p key={`output-lexical-item-${i}`}>{lexicalItem}</p>) : <></>}
</div>
</div>
);

View file

@ -20,7 +20,7 @@ describe('Output', () => {
});
it('renders output lexicon list from output hook', () => {
const { getByTestId } = render(<Output results={['word', 'lex', 'word']}/>);
const { getByTestId } = render(<Output results={[{pass: 'test', lexicon: ['word', 'lex', 'word']}]}/>);
expect(getByTestId('Output-lexicon')).toContainHTML('<p>word</p><p>lex</p><p>word</p>');
});

View file

@ -11,12 +11,12 @@ export const initState = (changesArgument: number = -1): stateType => {
{
name: 'epoch 1',
changes: [
'[+ occlusive - nasal]>[+ occlusive nasal]/n_.',
'at>ta/._#',
'[+ sonorant - low rounded high back]>0/._.',
'nn>nun/._.',
'[+ nasal][+ obstruent]>[+ nasal obstruent aspirated ]/#_.',
'[+ sonorant rounded]>[+ sonorant - rounded]/._#'
'[+ occlusive - nasal]>[+ occlusive + nasal]/n_.',
// 'at>ta/._#',
// '[+ sonorant - low rounded high back]>0/._.',
// 'nn>nun/._.',
// '[+ nasal][+ obstruent]>[+ nasal obstruent aspirated ]/#_.',
// '[+ sonorant rounded]>[+ sonorant - rounded]/._#'
]
}
],

View file

@ -194,8 +194,8 @@ export const run = (state: stateType, action: resultsAction): stateType => {
const pass = {
pass: epoch.name,
results: stringifiedPassResults
lexicon: stringifiedPassResults
}
return {...state, results: pass }
return {...state, results: [pass] }
}

View file

@ -89,12 +89,28 @@ describe('Results', () => {
it('results returned from first sound change rule', () => {
const action = {type: 'RUN'};
state = initState(0)
expect(stateReducer(state, action).results).toEqual({
expect(stateReducer(state, action).results).toEqual([
{
pass: 'epoch 1',
results: [
lexicon: [
'anna', 'anat', 'anət', 'anna', 'tan', 'ənna'
]
})
}
]);
});
if('results returned from sound change suite', () => {
const action = {type: 'RUN'};
state = initState()
console.log(stateReducer(state, action).results)
expect(stateReducer(state, action).results).toEqual([
{
pass: 'epoch 1',
lexicon: [
'anna', 'anat', 'anət', 'anna', 'tan', 'ənna'
]
}
]);
});
});