salix/back/models/specs/mailAliasAccount.spec.js

58 lines
1.6 KiB
JavaScript
Raw Normal View History

const models = require('vn-loopback/server/server').models;
2023-12-04 08:41:24 +00:00
describe('loopback model MailAliasAccount', () => {
2024-06-14 06:39:57 +00:00
const ctx = beforeAll.getCtx();
it('should add a mail Alias', async() => {
const tx = await models.MailAliasAccount.beginTransaction({});
let error;
try {
2024-06-14 06:39:57 +00:00
const options = {transaction: tx, ctx};
2023-12-04 08:40:57 +00:00
await models.MailAliasAccount.create({mailAlias: 2, account: 5}, options);
await tx.rollback();
} catch (e) {
await tx.rollback();
error = e;
}
expect(error).toBeUndefined();
});
it('should add a mail Alias of an inherit role', async() => {
const tx = await models.MailAliasAccount.beginTransaction({});
let error;
try {
2024-06-14 06:39:57 +00:00
const options = {transaction: tx, ctx};
2023-12-04 08:40:57 +00:00
await models.MailAliasAccount.create({mailAlias: 3, account: 5}, options);
await tx.rollback();
} catch (e) {
await tx.rollback();
error = e;
}
expect(error).toBeUndefined();
});
it('should delete a mail Alias', async() => {
const tx = await models.MailAliasAccount.beginTransaction({});
let error;
try {
const options = {transaction: tx, accessToken: {userId: 1}};
const mailAclId = 2;
await models.MailAliasAccount.destroyAll({id: mailAclId}, options);
await tx.rollback();
} catch (e) {
await tx.rollback();
error = e;
}
expect(error).toBeUndefined();
});
});