mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-05-18 22:02:07 -04: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 --------- Co-authored-by: MartinBraquet <martin.braquet@gmail.com>
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
jest.mock('shared/supabase/init');
|
|
|
|
import { createBookmarkedSearch } from "api/create-bookmarked-search";
|
|
import { AuthedUser } from "api/helpers/endpoint";
|
|
import * as supabaseInit from "shared/supabase/init";
|
|
|
|
describe('createBookmarkedSearch', () => {
|
|
let mockPg: any;
|
|
beforeEach(() => {
|
|
jest.resetAllMocks();
|
|
|
|
mockPg = {
|
|
one: jest.fn(),
|
|
};
|
|
|
|
(supabaseInit.createSupabaseDirectClient as jest.Mock)
|
|
.mockReturnValue(mockPg);
|
|
});
|
|
|
|
afterEach(() => {
|
|
jest.restoreAllMocks();
|
|
});
|
|
|
|
describe('should', () => {
|
|
it('insert a bookmarked search into the database', async () => {
|
|
const mockProps = {
|
|
search_filters: 'mock_search_filters',
|
|
location: 'mock_location',
|
|
search_name: 'mock_search_name'
|
|
};
|
|
const mockAuth = { uid: '321' } as AuthedUser;
|
|
const mockReq = {} as any;
|
|
|
|
await createBookmarkedSearch(mockProps, mockAuth, mockReq)
|
|
expect(mockPg.one).toBeCalledTimes(1)
|
|
expect(mockPg.one).toHaveBeenCalledWith(
|
|
expect.stringContaining('INSERT INTO bookmarked_searches'),
|
|
[
|
|
mockAuth.uid,
|
|
mockProps.search_filters,
|
|
mockProps.location,
|
|
mockProps.search_name
|
|
]
|
|
);
|
|
});
|
|
});
|
|
}); |