This commit is contained in:
parent
db55c3e81b
commit
b7e3e9fa71
|
@ -0,0 +1,26 @@
|
||||||
|
const {models} = require('vn-loopback/server/server');
|
||||||
|
|
||||||
|
describe('Account addMailAlias()', () => {
|
||||||
|
it('should throw an error when the user is not a superior', async() => {
|
||||||
|
const ctx = {req: {accessToken: {userId: 1}}};
|
||||||
|
const employeeId = 1;
|
||||||
|
|
||||||
|
let error;
|
||||||
|
try {
|
||||||
|
await models.Account.addMailAlias(ctx, employeeId, 1);
|
||||||
|
} catch (e) {
|
||||||
|
error = e.message;
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(error).toEqual(`You don't have enough privileges`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should add a mail alias', async() => {
|
||||||
|
const ctx = {req: {accessToken: {userId: 9}}};
|
||||||
|
const employeeId = 1;
|
||||||
|
|
||||||
|
const result = await models.Account.addMailAlias(ctx, employeeId, 2);
|
||||||
|
|
||||||
|
expect(result).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,35 @@
|
||||||
|
const {models} = require('vn-loopback/server/server');
|
||||||
|
|
||||||
|
describe('Account changeMailForwarding()', () => {
|
||||||
|
it('should throw an error when the user is not himself or a superior', async() => {
|
||||||
|
const ctx = {req: {accessToken: {userId: 1}}};
|
||||||
|
const developerId = 9;
|
||||||
|
|
||||||
|
let error;
|
||||||
|
try {
|
||||||
|
await models.Account.changeMailForwarding(ctx, developerId, 'alias@test.test');
|
||||||
|
} catch (e) {
|
||||||
|
error = e.message;
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(error).toEqual(`You don't have enough privileges`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should change a mail forwarding when the user is himself', async() => {
|
||||||
|
const ctx = {req: {accessToken: {userId: 1}}};
|
||||||
|
const employeeId = 1;
|
||||||
|
|
||||||
|
const result = await models.Account.changeMailForwarding(ctx, employeeId, 'alias@test.test');
|
||||||
|
|
||||||
|
expect(result).toBeDefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should change a mail forwarding when the user is a superior', async() => {
|
||||||
|
const ctx = {req: {accessToken: {userId: 9}}};
|
||||||
|
const employeeId = 1;
|
||||||
|
|
||||||
|
const result = await models.Account.changeMailForwarding(ctx, employeeId, 'alias@test.test');
|
||||||
|
|
||||||
|
expect(result).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,24 @@
|
||||||
|
const {models} = require('vn-loopback/server/server');
|
||||||
|
|
||||||
|
describe('Account deleteMailAlias()', () => {
|
||||||
|
it('should throw an error when the user is not a superior', async() => {
|
||||||
|
const ctx = {req: {accessToken: {userId: 1}}};
|
||||||
|
|
||||||
|
let error;
|
||||||
|
try {
|
||||||
|
await models.Account.deleteMailAlias(ctx, 1);
|
||||||
|
} catch (e) {
|
||||||
|
error = e.message;
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(error).toEqual(`You don't have enough privileges`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should delete a mail alias', async() => {
|
||||||
|
const ctx = {req: {accessToken: {userId: 9}}};
|
||||||
|
|
||||||
|
const result = await models.Account.deleteMailAlias(ctx, 1);
|
||||||
|
|
||||||
|
expect(result).toBeDefined();
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue