mirror of
https://github.com/strapi/strapi.git
synced 2025-11-02 10:55:37 +00:00
Fix tests
This commit is contained in:
parent
eca2c57a71
commit
18fbe664d7
@ -174,13 +174,29 @@ describe('User Controller', () => {
|
|||||||
pagination,
|
pagination,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
const state = {
|
||||||
|
userAbility: {
|
||||||
|
can: jest.fn(),
|
||||||
|
cannot: jest.fn(() => false),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
const sanitizeUser = jest.fn((user) => user);
|
const sanitizeUser = jest.fn((user) => user);
|
||||||
const ctx = createContext({});
|
const ctx = createContext({});
|
||||||
|
ctx.state = state;
|
||||||
|
|
||||||
|
const createPermissionsManager = jest.fn(() => ({
|
||||||
|
ability: state.userAbility,
|
||||||
|
sanitizeQuery: (query) => query,
|
||||||
|
}));
|
||||||
|
|
||||||
global.strapi = {
|
global.strapi = {
|
||||||
admin: {
|
admin: {
|
||||||
services: {
|
services: {
|
||||||
user: { findPage, sanitizeUser },
|
user: { findPage, sanitizeUser },
|
||||||
|
permission: {
|
||||||
|
createPermissionsManager,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -199,13 +215,30 @@ describe('User Controller', () => {
|
|||||||
pagination,
|
pagination,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
const state = {
|
||||||
|
userAbility: {
|
||||||
|
can: jest.fn(),
|
||||||
|
cannot: jest.fn(() => false),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
const sanitizeUser = jest.fn((user) => user);
|
const sanitizeUser = jest.fn((user) => user);
|
||||||
const ctx = createContext({ query: { _q: 'foo' } });
|
const ctx = createContext({ query: { _q: 'foo' } });
|
||||||
|
|
||||||
|
ctx.state = state;
|
||||||
|
|
||||||
|
const createPermissionsManager = jest.fn(() => ({
|
||||||
|
ability: state.userAbility,
|
||||||
|
sanitizeQuery: (query) => query,
|
||||||
|
}));
|
||||||
|
|
||||||
global.strapi = {
|
global.strapi = {
|
||||||
admin: {
|
admin: {
|
||||||
services: {
|
services: {
|
||||||
user: { findPage, sanitizeUser },
|
user: { findPage, sanitizeUser },
|
||||||
|
permission: {
|
||||||
|
createPermissionsManager,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@ -23,6 +23,9 @@ describe('Single Types', () => {
|
|||||||
create: jest.fn(() => false),
|
create: jest.fn(() => false),
|
||||||
},
|
},
|
||||||
buildReadQuery: jest.fn((query) => query),
|
buildReadQuery: jest.fn((query) => query),
|
||||||
|
sanitizedQuery: {
|
||||||
|
read: (q) => q,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
global.strapi = {
|
global.strapi = {
|
||||||
@ -101,6 +104,9 @@ describe('Single Types', () => {
|
|||||||
sanitizeCreateInput: (obj) => obj,
|
sanitizeCreateInput: (obj) => obj,
|
||||||
sanitizeOutput: (obj) => obj,
|
sanitizeOutput: (obj) => obj,
|
||||||
buildReadQuery: jest.fn((query) => query),
|
buildReadQuery: jest.fn((query) => query),
|
||||||
|
sanitizedQuery: {
|
||||||
|
update: (q) => q,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const createFn = jest.fn(() => ({}));
|
const createFn = jest.fn(() => ({}));
|
||||||
@ -215,6 +221,9 @@ describe('Single Types', () => {
|
|||||||
},
|
},
|
||||||
sanitizeOutput: jest.fn((obj) => obj),
|
sanitizeOutput: jest.fn((obj) => obj),
|
||||||
buildReadQuery: jest.fn((query) => query),
|
buildReadQuery: jest.fn((query) => query),
|
||||||
|
sanitizedQuery: {
|
||||||
|
delete: (q) => q,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteFn = jest.fn(() => ({}));
|
const deleteFn = jest.fn(() => ({}));
|
||||||
@ -309,6 +318,9 @@ describe('Single Types', () => {
|
|||||||
},
|
},
|
||||||
sanitizeOutput: jest.fn((obj) => obj),
|
sanitizeOutput: jest.fn((obj) => obj),
|
||||||
buildReadQuery: jest.fn((query) => query),
|
buildReadQuery: jest.fn((query) => query),
|
||||||
|
sanitizedQuery: {
|
||||||
|
publish: (q) => q,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const publishFn = jest.fn(() => ({}));
|
const publishFn = jest.fn(() => ({}));
|
||||||
@ -403,6 +415,9 @@ describe('Single Types', () => {
|
|||||||
},
|
},
|
||||||
sanitizeOutput: jest.fn((obj) => obj),
|
sanitizeOutput: jest.fn((obj) => obj),
|
||||||
buildReadQuery: jest.fn((query) => query),
|
buildReadQuery: jest.fn((query) => query),
|
||||||
|
sanitizedQuery: {
|
||||||
|
unpublish: (q) => q,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const unpublishFn = jest.fn(() => ({}));
|
const unpublishFn = jest.fn(() => ({}));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user