23 lines
775 B
JavaScript
23 lines
775 B
JavaScript
|
const app = require('vn-loopback/server/server');
|
||
|
|
||
|
describe('loopback model NotificationSubscription', () => {
|
||
|
it('Should fail to delete a notification if the user is not editing itself or a subordinate', async() => {
|
||
|
const user = 9;
|
||
|
const notificationSubscriptionId = 2;
|
||
|
const ctx = {req: {accessToken: {userId: user}}};
|
||
|
const models = app.models;
|
||
|
const notification = await models.NotificationSubscription.findById(notificationSubscriptionId);
|
||
|
|
||
|
let error;
|
||
|
|
||
|
try {
|
||
|
await models.NotificationSubscription.deleteNotification(ctx, notification.id);
|
||
|
} catch (e) {
|
||
|
error = e;
|
||
|
}
|
||
|
|
||
|
expect(error.message).toContain('You dont have permission to modify this user');
|
||
|
});
|
||
|
});
|
||
|
|