Merge branch 'dev' of https://git.verdnatura.es/salix into dev
This commit is contained in:
commit
ca7e299fbc
|
@ -1,15 +0,0 @@
|
|||
const app = require('../../../../server/server');
|
||||
const catchErrors = require('../../../../../../services/utils/jasmineHelpers').catchErrors;
|
||||
|
||||
describe('Client listWorkers', () => {
|
||||
it('should call the listWorkers()', done => {
|
||||
app.models.Client.listWorkers()
|
||||
.then(result => {
|
||||
let amountOfEmployees = Object.keys(result).length;
|
||||
|
||||
expect(amountOfEmployees).toEqual(6);
|
||||
done();
|
||||
})
|
||||
.catch(catchErrors(done));
|
||||
});
|
||||
});
|
|
@ -1,4 +1,4 @@
|
|||
const app = require('../../../../server/server');
|
||||
const app = require('../../../../../client/server/server');
|
||||
const catchErrors = require('../../../../../../services/utils/jasmineHelpers').catchErrors;
|
||||
|
||||
describe('Client activeSalesPerson', () => {
|
|
@ -1,4 +1,4 @@
|
|||
const app = require('../../../../server/server');
|
||||
const app = require('../../../../../client/server/server');
|
||||
const catchErrors = require('../../../../../../services/utils/jasmineHelpers').catchErrors;
|
||||
const restoreFixtures = require('../../../../../../services/db/testing_fixtures');
|
||||
|
||||
|
@ -64,21 +64,20 @@ describe('Client addressesPropagateRe', () => {
|
|||
|
||||
expect(result).toBe(true);
|
||||
app.models.Address.find({where: {clientFk: id}})
|
||||
.then(result => {
|
||||
expect(result[0].isEqualizated).toBeTruthy();
|
||||
expect(result[1].isEqualizated).toBeTruthy();
|
||||
done();
|
||||
});
|
||||
.then(result => {
|
||||
expect(result[0].isEqualizated).toBeTruthy();
|
||||
expect(result[1].isEqualizated).toBeTruthy();
|
||||
done();
|
||||
});
|
||||
};
|
||||
|
||||
app.models.Address.find({where: {clientFk: id}})
|
||||
.then(result => {
|
||||
expect(result[0].isEqualizated).toBeFalsy();
|
||||
expect(result[1].isEqualizated).toBeFalsy();
|
||||
})
|
||||
.then(() => {
|
||||
app.models.Client.addressesPropagateRe(id, data, callback);
|
||||
})
|
||||
.catch(catchErrors(done));
|
||||
.then(result => {
|
||||
expect(result[0].isEqualizated).toBeFalsy();
|
||||
expect(result[1].isEqualizated).toBeFalsy();
|
||||
})
|
||||
.then(() => {
|
||||
app.models.Client.addressesPropagateRe(id, data, callback);
|
||||
})
|
||||
.catch(catchErrors(done));
|
||||
});
|
||||
});
|
|
@ -1,4 +1,4 @@
|
|||
const app = require('../../../../server/server');
|
||||
const app = require('../../../../../client/server/server');
|
||||
const catchErrors = require('../../../../../../services/utils/jasmineHelpers').catchErrors;
|
||||
|
||||
describe('Client card', () => {
|
|
@ -1,4 +1,4 @@
|
|||
const app = require('../../../../server/server');
|
||||
const app = require('../../../../../client/server/server');
|
||||
const catchErrors = require('../../../../../../services/utils/jasmineHelpers').catchErrors;
|
||||
const restoreFixtures = require('../../../../../../services/db/testing_fixtures');
|
||||
|
||||
|
@ -65,64 +65,64 @@ describe('Client Create', () => {
|
|||
|
||||
it('should find Charles Xavier', done => {
|
||||
app.models.Account.findOne({where: {name: 'CharlesXavier'}})
|
||||
.then(account => {
|
||||
expect(account.name).toEqual('CharlesXavier');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("should not find Deadpool as he's not created yet", done => {
|
||||
app.models.Account.findOne({where: {name: newAccountData.userName}})
|
||||
.then(account => {
|
||||
expect(account).toEqual(null);
|
||||
app.models.Client.findOne({where: {name: newAccountData.name}})
|
||||
.then(client => {
|
||||
expect(client).toEqual(null);
|
||||
.then(account => {
|
||||
expect(account.name).toEqual('CharlesXavier');
|
||||
done();
|
||||
});
|
||||
})
|
||||
.catch(catchErrors(done));
|
||||
});
|
||||
|
||||
it(`should not find Deadpool as he's not created yet`, done => {
|
||||
app.models.Account.findOne({where: {name: newAccountData.userName}})
|
||||
.then(account => {
|
||||
expect(account).toEqual(null);
|
||||
app.models.Client.findOne({where: {name: newAccountData.name}})
|
||||
.then(client => {
|
||||
expect(client).toEqual(null);
|
||||
done();
|
||||
});
|
||||
})
|
||||
.catch(catchErrors(done));
|
||||
});
|
||||
|
||||
it('should not be able to create a user if exists', done => {
|
||||
app.models.Client.findOne({where: {name: 'Charles Xavier'}})
|
||||
.then(client => {
|
||||
app.models.Account.findOne({where: {id: client.id}})
|
||||
.then(account => {
|
||||
let formerAccountData = {
|
||||
name: client.name,
|
||||
userName: account.name,
|
||||
email: client.email,
|
||||
fi: client.fi,
|
||||
socialName: client.socialName
|
||||
};
|
||||
.then(client => {
|
||||
app.models.Account.findOne({where: {id: client.id}})
|
||||
.then(account => {
|
||||
let formerAccountData = {
|
||||
name: client.name,
|
||||
userName: account.name,
|
||||
email: client.email,
|
||||
fi: client.fi,
|
||||
socialName: client.socialName
|
||||
};
|
||||
|
||||
app.models.Client.createWithUser(formerAccountData, (err, client) => {
|
||||
expect(err.details.codes.name[0]).toEqual('uniqueness');
|
||||
done();
|
||||
});
|
||||
});
|
||||
})
|
||||
.catch(catchErrors(done));
|
||||
app.models.Client.createWithUser(formerAccountData, (err, client) => {
|
||||
expect(err.details.codes.name[0]).toEqual('uniqueness');
|
||||
done();
|
||||
});
|
||||
});
|
||||
})
|
||||
.catch(catchErrors(done));
|
||||
});
|
||||
|
||||
it('should create a new account', done => {
|
||||
app.models.Client.createWithUser(newAccountData, (error, client) => {
|
||||
if (error) return catchErrors(done)(error);
|
||||
app.models.Account.findOne({where: {name: newAccountData.userName}})
|
||||
.then(account => {
|
||||
expect(account.name).toEqual(newAccountData.userName);
|
||||
app.models.Client.findOne({where: {name: newAccountData.name}})
|
||||
.then(client => {
|
||||
expect(client.id).toEqual(account.id);
|
||||
expect(client.name).toEqual(newAccountData.name);
|
||||
expect(client.email).toEqual(newAccountData.email);
|
||||
expect(client.fi).toEqual(newAccountData.fi);
|
||||
expect(client.socialName).toEqual(newAccountData.socialName);
|
||||
done();
|
||||
});
|
||||
})
|
||||
.catch(catchErrors(done));
|
||||
.then(account => {
|
||||
expect(account.name).toEqual(newAccountData.userName);
|
||||
app.models.Client.findOne({where: {name: newAccountData.name}})
|
||||
.then(client => {
|
||||
expect(client.id).toEqual(account.id);
|
||||
expect(client.name).toEqual(newAccountData.name);
|
||||
expect(client.email).toEqual(newAccountData.email);
|
||||
expect(client.fi).toEqual(newAccountData.fi);
|
||||
expect(client.socialName).toEqual(newAccountData.socialName);
|
||||
done();
|
||||
});
|
||||
})
|
||||
.catch(catchErrors(done));
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,4 +1,4 @@
|
|||
const app = require('../../../../server/server');
|
||||
const app = require('../../../../../client/server/server');
|
||||
const catchErrors = require('../../../../../../services/utils/jasmineHelpers').catchErrors;
|
||||
|
||||
describe('Client hasCustomerRole', () => {
|
|
@ -1,4 +1,4 @@
|
|||
const app = require('../../../../server/server');
|
||||
const app = require('../../../../../client/server/server');
|
||||
const catchErrors = require('../../../../../../services/utils/jasmineHelpers');
|
||||
|
||||
describe('Client addresses', () => {
|
|
@ -0,0 +1,15 @@
|
|||
const app = require('../../../../../client/server/server');
|
||||
const catchErrors = require('../../../../../../services/utils/jasmineHelpers').catchErrors;
|
||||
|
||||
describe('Client listWorkers', () => {
|
||||
it('should call the listWorkers()', done => {
|
||||
app.models.Client.listWorkers()
|
||||
.then(result => {
|
||||
let amountOfEmployees = Object.keys(result).length;
|
||||
|
||||
expect(amountOfEmployees).toEqual(6);
|
||||
done();
|
||||
})
|
||||
.catch(catchErrors(done));
|
||||
});
|
||||
});
|
|
@ -18,6 +18,7 @@ jasmine.loadConfig({
|
|||
spec_dir: 'services',
|
||||
spec_files: [
|
||||
'auth/server/**/*[sS]pec.js',
|
||||
'loopback/common/**/*[sS]pec.js',
|
||||
'client/common/**/*[sS]pec.js'
|
||||
],
|
||||
helpers: [
|
||||
|
|
Loading…
Reference in New Issue