mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-02-07 20:40:59 -05:00
* setting up test structure * . * added playwright config file, deleted original playwright folder and moved "some.test" file * continued test structure setup * Updating test folder structure * Added database seeding script and backend testing folder structure * removed the database test * Replaced db seeding script * Updated userInformation.ts to use values from choices.tsx * merge prep * removing extra unit test, moving api test to correct folder * Pushing to get help with sql Unit test * Updating get-profiles unit tests * Added more unit tests * . * Added more unit tests * Added getSupabaseToken unit test * . * excluding supabase token test so ci can pass * . * Seperated the seedDatabase func into its own file so it can be accessed seperatly * Fixed failing test * . * . * Fix tests * Fix lint * Clean * Fixed module paths in compute-score unit test * Updated root tsconfig to recognise backend/shared * Added create comment unit test * Added some unit tests * Working on createProfile return issue * . * Fixes * Updated Create profile unit test * Updating create user unit test * Add create-user unit tests * . * Added more unit tests * Added more unit tests * . * Apply suggestion from @MartinBraquet * . * Added unit tests * Added unit tests --------- Co-authored-by: MartinBraquet <martin.braquet@gmail.com>
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
jest.mock('shared/supabase/init');
|
|
|
|
import { getMessagesCount } from "api/get-messages-count";
|
|
import { AuthedUser } from "api/helpers/endpoint";
|
|
import * as supabaseInit from "shared/supabase/init";
|
|
|
|
describe('getMessagesCount', () => {
|
|
let mockPg = {} as any;
|
|
beforeEach(() => {
|
|
jest.resetAllMocks();
|
|
mockPg = {
|
|
one: jest.fn()
|
|
};
|
|
(supabaseInit.createSupabaseDirectClient as jest.Mock)
|
|
.mockReturnValue(mockPg);
|
|
});
|
|
afterEach(() => {
|
|
jest.restoreAllMocks();
|
|
});
|
|
|
|
describe('when given valid input', () => {
|
|
it('should get message count', async () => {
|
|
const mockProps = {} as any;
|
|
const mockAuth = { uid: '321' } as AuthedUser;
|
|
const mockReq = {} as any;
|
|
const mockResults = { count: "10"};
|
|
|
|
(mockPg.one as jest.Mock).mockResolvedValue(mockResults);
|
|
|
|
const result: any = await getMessagesCount(mockProps, mockAuth, mockReq);
|
|
|
|
expect(result.count).toBe(Number(mockResults.count));
|
|
expect(mockPg.one).toBeCalledTimes(1);
|
|
expect(mockPg.one).toBeCalledWith(
|
|
expect.stringContaining('SELECT COUNT(*) AS count'),
|
|
expect.any(Object)
|
|
);
|
|
});
|
|
});
|
|
}); |