Skip to content

Commit

Permalink
onChange test
Browse files Browse the repository at this point in the history
  • Loading branch information
REllEK-IO committed May 1, 2024
1 parent 95f9e2a commit 738af78
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/test/onChange.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*<$
For the asynchronous graph programming framework Stratimux, generate a test that ensures that ActionStrategies are working as intended.
$>*/
/*<#*/
import { createAxium } from '../model/axium';
import { strategyBegin } from '../model/actionStrategy';
import { selectState } from '../model/selector';
import { CounterState, createCounterConcept, countingStrategy, counterName } from '../concepts/counter/counter.concept';
import { AxiumState } from '../concepts/axium/axium.concept';
import { countingTopic } from '../concepts/counter/strategies/counting.strategy';
import { createStage } from '../model/stagePlanner';
import { counterSelectCount } from '../concepts/counter/counter.selector';
import { axiumSelectLastStrategy } from '../concepts/axium/axium.selector';

test('Axium Counting Strategy Test', (done) => {
const axium = createAxium('axiumStrategyTest', [createCounterConcept()], true, true);
const plan = axium.plan('Counting Strategy Stage',
[
createStage((_, dispatch) => {
dispatch(strategyBegin(countingStrategy()), {
iterateStage: true
});
}),
createStage((concepts, _, changes) => {
console.log(changes);
const axiumState = concepts[0].state as AxiumState;
if (axiumState.lastStrategy === countingTopic) {
const counter = selectState<CounterState>(concepts, counterName);
expect(counter?.count).toBe(1);
setTimeout(() => {done();}, 500);
plan.conclude();
axium.close();
}
}, {
selectors: [counterSelectCount, axiumSelectLastStrategy]
})
]);
});
/*#>*/

0 comments on commit 738af78

Please sign in to comment.