mirror of
https://github.com/strapi/strapi.git
synced 2025-08-08 00:37:38 +00:00
46 lines
919 B
JavaScript
46 lines
919 B
JavaScript
'use strict';
|
|
|
|
const roleController = require('../role');
|
|
|
|
const createContext = ({ params = {}, query = {}, body = {} }, overrides = {}) => ({
|
|
params,
|
|
query,
|
|
request: {
|
|
body,
|
|
},
|
|
...overrides,
|
|
});
|
|
|
|
describe('Role controller', () => {
|
|
describe('getPermissions', () => {
|
|
test('Fails if role does not exist', async () => {
|
|
const findOne = jest.fn(() => Promise.resolve());
|
|
const notFound = jest.fn(() => Promise.resolve());
|
|
|
|
const ctx = createContext(
|
|
{
|
|
params: { id: 1 },
|
|
},
|
|
{
|
|
notFound,
|
|
}
|
|
);
|
|
|
|
global.strapi = {
|
|
admin: {
|
|
services: {
|
|
role: {
|
|
findOne,
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
await roleController.getPermissions(ctx);
|
|
|
|
expect(findOne).toHaveBeenCalledWith({ id: ctx.params.id });
|
|
expect(notFound).toHaveBeenCalled();
|
|
});
|
|
});
|
|
});
|