Skip to content

Commit

Permalink
feat(simulator): tick on out of bounds elementChanged
Browse files Browse the repository at this point in the history
This ensures we can use the existing `elementChanged` logic
if the simulation is not currently running, i.e. when
configuring the simulator pre-execute.
  • Loading branch information
nikku committed Dec 14, 2021
1 parent d4a0842 commit 5323070
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/simulator/Simulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,12 @@ export default function Simulator(injector, eventBus) {

function elementChanged(element) {
changedElements.add(element);

// tick, unless jobs are queued
// (and tick is going to happen naturally)
if (!jobs.length) {
emit('tick');
}
}

function scopeChanged(scope) {
Expand Down
15 changes: 15 additions & 0 deletions test/spec/simulator/SimulatorSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ describe('simulator', function() {
expect(spy).to.have.been.calledOnce;
});


verify('sub-process', (simulator) => {

// when
const spy = sinon.spy();

simulator.on('tick', spy);

simulator.waitAtElement(element('SUB'));

// then
expect(spy).to.have.been.calledOnce;
});

});


Expand Down Expand Up @@ -142,6 +156,7 @@ describe('simulator', function() {

});


describe('scopeChanged', function() {

it('should emit on scope creation');
Expand Down

0 comments on commit 5323070

Please sign in to comment.