From 418d7a2d12aaa58f97f43c575b30eb26de652fc7 Mon Sep 17 00:00:00 2001 From: joan Date: Wed, 7 Apr 2021 14:14:31 +0200 Subject: [PATCH] Updated unit test --- modules/client/front/sample/create/index.js | 6 +++--- modules/client/front/sample/create/index.spec.js | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/modules/client/front/sample/create/index.js b/modules/client/front/sample/create/index.js index c2ac99ae5..0eaeddc20 100644 --- a/modules/client/front/sample/create/index.js +++ b/modules/client/front/sample/create/index.js @@ -9,8 +9,6 @@ class Controller extends Section { clientFk: this.$params.id, companyId: this.vnConfig.companyFk }; - - this.getWorkerEmail(); } get client() { @@ -20,8 +18,10 @@ class Controller extends Section { set client(value) { this._client = value; - if (value) + if (value) { this.clientSample.recipient = value.email; + this.getWorkerEmail(); + } } get companyId() { diff --git a/modules/client/front/sample/create/index.spec.js b/modules/client/front/sample/create/index.spec.js index 40fa237b6..37d322b5f 100644 --- a/modules/client/front/sample/create/index.spec.js +++ b/modules/client/front/sample/create/index.spec.js @@ -179,5 +179,17 @@ describe('Client', () => { expect(controller.$state.go).toHaveBeenCalledWith('client.card.sample.index'); }); }); + + describe('getWorkerEmail()', () => { + it(`should perform a query and then set the replyTo property to the clientSample object`, () => { + const expectedEmail = 'batman@arkhamcity.com'; + const serializedParams = $httpParamSerializer({filter: {where: {}}}); + $httpBackend.expect('GET', `EmailUsers?${serializedParams}`).respond([{email: expectedEmail}]); + controller.getWorkerEmail(); + $httpBackend.flush(); + + expect(controller.clientSample.replyTo).toEqual(expectedEmail); + }); + }); }); });