This commit is contained in:
parent
e9c1f125a5
commit
391f418883
|
@ -13,8 +13,16 @@ describe('Client Create', () => {
|
|||
businessTypeFk: 'florist',
|
||||
provinceFk: 1
|
||||
};
|
||||
|
||||
const errorMail = `An email is necessary`;
|
||||
const newAccount2 = {
|
||||
userName: 'Deadpool',
|
||||
fi: '16195279J',
|
||||
name: 'Wade',
|
||||
socialName: 'DEADPOOL MARVEL',
|
||||
street: 'WALL STREET',
|
||||
city: 'New York',
|
||||
businessTypeFk: 'florist',
|
||||
provinceFk: 1
|
||||
};
|
||||
|
||||
beforeAll(async() => {
|
||||
const activeCtx = {
|
||||
|
@ -53,26 +61,18 @@ describe('Client Create', () => {
|
|||
it('should not create a new account', async() => {
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
||||
let error;
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const client = await models.Client.createWithUser(newAccount, options);
|
||||
const account = await models.VnUser.findOne({where: {name: newAccount.userName}}, options);
|
||||
|
||||
expect(account.name).toEqual(newAccount.userName);
|
||||
expect(client.id).toEqual(account.id);
|
||||
expect(client.name).toEqual(newAccount.name);
|
||||
expect(client.fi).toEqual(newAccount.fi);
|
||||
expect(client.socialName).toEqual(newAccount.socialName);
|
||||
expect(client.businessTypeFk).toEqual(newAccount.businessTypeFk);
|
||||
await models.Client.createWithUser(newAccount2, options);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
error = e.message;
|
||||
|
||||
expect(errorMail).toEqual(`An email is necessary`);
|
||||
expect(error).toEqual(`An email is necessary`);
|
||||
await tx.rollback();
|
||||
}
|
||||
});
|
||||
|
||||
it('should create a new account', async() => {
|
||||
|
|
Loading…
Reference in New Issue