Skip to content

Commit

Permalink
Added reproducing test for #50.
Browse files Browse the repository at this point in the history
  • Loading branch information
weekens committed Dec 15, 2020
1 parent a2c542b commit f710767
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion test/typescript/test-hot-config-change.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import * as actors from '../../';
import {expect} from 'chai';
import {Actor, ActorRef, ActorSystem} from '../../index';
import { Actor, ActorDefinition, ActorRef, ActorSystem } from '../../index';
import {afterEach, beforeEach} from 'mocha';
import * as common from '../../lib/utils/common';
import _ = require('underscore');
Expand Down Expand Up @@ -194,6 +194,42 @@ describe('Hot configuration change', () => {
expect(finalPid).to.be.not.equal(pid2);
expect(finalPid).to.be.not.equal(pid3);
});

it('should respect custom parameters', async () => {
class TestActor implements ActorDefinition {
private selfActor: Actor;

initialize(selfActor: Actor): void {
this.selfActor = selfActor;
}

test() {
return `${this.selfActor.getCustomParameters().greeting} ${process.pid}`;
}

destroy(): void {
// Nothing to do.
}
}

let testActor = await rootActor.createChild(TestActor, {
mode: 'in-memory',
customParameters: {
greeting: 'Hello!'
}
});

let message = await testActor.sendAndReceive('test');

expect(message).to.match(/Hello! \d+/);

await testActor.changeConfiguration({ mode: 'forked' });

let forkedMessage = await testActor.sendAndReceive('test');

expect(forkedMessage).to.match(/Hello! \d+/);
expect(forkedMessage).to.be.not.equal(message);
});
});

describe('changeGlobalConfiguration()', () => {
Expand Down

0 comments on commit f710767

Please sign in to comment.