refs #5235 added setClientSample(), fixed tests
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
ce68301885
commit
ca1f5480ae
|
@ -5,10 +5,6 @@ import './style.scss';
|
|||
class Controller extends Section {
|
||||
constructor($element, $, vnEmail) {
|
||||
super($element, $);
|
||||
this.clientSample = {
|
||||
clientFk: this.$params.id,
|
||||
companyId: this.vnConfig.companyFk
|
||||
};
|
||||
this.vnEmail = vnEmail;
|
||||
}
|
||||
|
||||
|
@ -19,10 +15,8 @@ class Controller extends Section {
|
|||
set client(value) {
|
||||
this._client = value;
|
||||
|
||||
if (value) {
|
||||
this.clientSample.recipient = value.email;
|
||||
this.getWorkerEmail();
|
||||
}
|
||||
if (value)
|
||||
this.setClientSample(value);
|
||||
}
|
||||
|
||||
get companyId() {
|
||||
|
@ -119,12 +113,17 @@ class Controller extends Section {
|
|||
.then(() => this.$state.go('client.card.sample.index'));
|
||||
}
|
||||
|
||||
getWorkerEmail() {
|
||||
setClientSample(client) {
|
||||
const userId = window.localStorage.currentUserWorkerId;
|
||||
const params = {filter: {where: {userFk: userId}}};
|
||||
this.$http.get('EmailUsers', params).then(res => {
|
||||
const [worker] = res && res.data;
|
||||
this.clientSample.replyTo = worker.email;
|
||||
this.clientSample = {
|
||||
clientFk: this.$params.id,
|
||||
companyId: this.vnConfig.companyFk,
|
||||
recipient: client.email,
|
||||
replyTo: worker.email
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -191,15 +191,19 @@ describe('Client', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('getWorkerEmail()', () => {
|
||||
describe('setClientSample()', () => {
|
||||
it(`should perform a query and then set the replyTo property to the clientSample object`, () => {
|
||||
const client = {email: 'test@example.com'};
|
||||
const expectedEmail = 'batman@arkhamcity.com';
|
||||
const serializedParams = $httpParamSerializer({filter: {where: {}}});
|
||||
$httpBackend.expect('GET', `EmailUsers?${serializedParams}`).respond([{email: expectedEmail}]);
|
||||
controller.getWorkerEmail();
|
||||
controller.setClientSample(client);
|
||||
$httpBackend.flush();
|
||||
|
||||
expect(controller.clientSample.replyTo).toEqual(expectedEmail);
|
||||
expect(controller.clientSample.clientFk).toEqual(controller.$params.id);
|
||||
expect(controller.clientSample.recipient).toEqual(client.email);
|
||||
expect(controller.clientSample.companyId).toEqual(controller.vnConfig.companyFk);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue