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