display results of run in Output component
This commit is contained in:
parent
3d0bde1c55
commit
a19102f82e
6 changed files with 36 additions and 19 deletions
|
@ -82,8 +82,8 @@ const PhonoChangeApplier = () => {
|
||||||
}
|
}
|
||||||
startingIndex = index;
|
startingIndex = index;
|
||||||
})
|
})
|
||||||
lexemeBundle.unshift(['#'])
|
// lexemeBundle.unshift(['#'])
|
||||||
lexemeBundle.push(['#'])
|
// lexemeBundle.push(['#'])
|
||||||
lexicalFeatureBundles.push(lexemeBundle);
|
lexicalFeatureBundles.push(lexemeBundle);
|
||||||
})
|
})
|
||||||
console.log(lexicalFeatureBundles)
|
console.log(lexicalFeatureBundles)
|
||||||
|
|
|
@ -2,12 +2,13 @@ import React from 'react';
|
||||||
import './Output.scss';
|
import './Output.scss';
|
||||||
|
|
||||||
const Output = props => {
|
const Output = props => {
|
||||||
|
const { results } = props;
|
||||||
return (
|
return (
|
||||||
<div className="Output" data-testid="Output">
|
<div className="Output" data-testid="Output">
|
||||||
<h3>Results of Run</h3>
|
<h3>Results of Run</h3>
|
||||||
|
|
||||||
<div data-testid="Output-lexicon">
|
<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>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -20,7 +20,7 @@ describe('Output', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('renders output lexicon list from output hook', () => {
|
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>');
|
expect(getByTestId('Output-lexicon')).toContainHTML('<p>word</p><p>lex</p><p>word</p>');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -11,12 +11,12 @@ export const initState = (changesArgument: number = -1): stateType => {
|
||||||
{
|
{
|
||||||
name: 'epoch 1',
|
name: 'epoch 1',
|
||||||
changes: [
|
changes: [
|
||||||
'[+ occlusive - nasal]>[+ occlusive nasal]/n_.',
|
'[+ occlusive - nasal]>[+ occlusive + nasal]/n_.',
|
||||||
'at>ta/._#',
|
// 'at>ta/._#',
|
||||||
'[+ sonorant - low rounded high back]>0/._.',
|
// '[+ sonorant - low rounded high back]>0/._.',
|
||||||
'nn>nun/._.',
|
// 'nn>nun/._.',
|
||||||
'[+ nasal][+ obstruent]>[+ nasal obstruent aspirated ]/#_.',
|
// '[+ nasal][+ obstruent]>[+ nasal obstruent aspirated ]/#_.',
|
||||||
'[+ sonorant rounded]>[+ sonorant - rounded]/._#'
|
// '[+ sonorant rounded]>[+ sonorant - rounded]/._#'
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
|
@ -194,8 +194,8 @@ export const run = (state: stateType, action: resultsAction): stateType => {
|
||||||
|
|
||||||
const pass = {
|
const pass = {
|
||||||
pass: epoch.name,
|
pass: epoch.name,
|
||||||
results: stringifiedPassResults
|
lexicon: stringifiedPassResults
|
||||||
}
|
}
|
||||||
|
|
||||||
return {...state, results: pass }
|
return {...state, results: [pass] }
|
||||||
}
|
}
|
|
@ -89,12 +89,28 @@ describe('Results', () => {
|
||||||
it('results returned from first sound change rule', () => {
|
it('results returned from first sound change rule', () => {
|
||||||
const action = {type: 'RUN'};
|
const action = {type: 'RUN'};
|
||||||
state = initState(0)
|
state = initState(0)
|
||||||
expect(stateReducer(state, action).results).toEqual({
|
expect(stateReducer(state, action).results).toEqual([
|
||||||
pass: 'epoch 1',
|
{
|
||||||
results: [
|
pass: 'epoch 1',
|
||||||
'anna', 'anat', 'anət', 'anna', 'tan', 'ənna'
|
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'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
Loading…
Reference in a new issue