From f710767f5611dbf9b23233c921fc6536c1802456 Mon Sep 17 00:00:00 2001 From: weekens Date: Tue, 15 Dec 2020 21:41:52 +0300 Subject: [PATCH] Added reproducing test for #50. --- test/typescript/test-hot-config-change.ts | 38 ++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/test/typescript/test-hot-config-change.ts b/test/typescript/test-hot-config-change.ts index cb4ae71..9169ca9 100644 --- a/test/typescript/test-hot-config-change.ts +++ b/test/typescript/test-hot-config-change.ts @@ -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'); @@ -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()', () => {