36 lines
1.4 KiB
TypeScript
36 lines
1.4 KiB
TypeScript
import 'reflect-metadata';
|
|
import { PERMISSION_KEY } from '../auth/decorators/permission.decorator';
|
|
import { OccupanciesController } from './occupancies.controller';
|
|
|
|
describe('OccupanciesController permissions', () => {
|
|
it('requires occupancy:delete for single and batch archive actions', () => {
|
|
expect(Reflect.getMetadata(PERMISSION_KEY, OccupanciesController.prototype.remove)).toEqual([
|
|
'occupancy:delete',
|
|
]);
|
|
expect(
|
|
Reflect.getMetadata(PERMISSION_KEY, OccupanciesController.prototype.batchRemove),
|
|
).toEqual(['occupancy:delete']);
|
|
});
|
|
|
|
it('keeps read-only endpoints on occupancy:view', () => {
|
|
expect(Reflect.getMetadata(PERMISSION_KEY, OccupanciesController.prototype.findAll)).toEqual([
|
|
'occupancy:view',
|
|
]);
|
|
expect(
|
|
Reflect.getMetadata(PERMISSION_KEY, OccupanciesController.prototype.exportExcel),
|
|
).toEqual(['occupancy:view']);
|
|
expect(
|
|
Reflect.getMetadata(PERMISSION_KEY, OccupanciesController.prototype.downloadTemplate),
|
|
).toEqual(['occupancy:view']);
|
|
});
|
|
|
|
it('requires occupancy:purge on permanent delete routes', () => {
|
|
expect(Reflect.getMetadata(PERMISSION_KEY, OccupanciesController.prototype.purge)).toEqual([
|
|
'occupancy:purge',
|
|
]);
|
|
expect(
|
|
Reflect.getMetadata(PERMISSION_KEY, OccupanciesController.prototype.batchPurge),
|
|
).toEqual(['occupancy:purge']);
|
|
});
|
|
});
|