mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-05-18 22:02:07 -04:00
Apply sqlmatch
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
jest.mock('shared/supabase/init');
|
||||
jest.mock('shared/compatibility/compute-scores');
|
||||
|
||||
import { deleteCompatibilityAnswer } from "api/delete-compatibility-answer";
|
||||
import {sqlMatch} from "common/test-utils";
|
||||
import {deleteCompatibilityAnswer} from "api/delete-compatibility-answer";
|
||||
import * as supabaseInit from "shared/supabase/init";
|
||||
import { recomputeCompatibilityScoresForUser } from "shared/compatibility/compute-scores";
|
||||
import { AuthedUser } from "api/helpers/endpoint";
|
||||
import {recomputeCompatibilityScoresForUser} from "shared/compatibility/compute-scores";
|
||||
import {AuthedUser} from "api/helpers/endpoint";
|
||||
|
||||
describe('deleteCompatibilityAnswers', () => {
|
||||
let mockPg = {} as any;
|
||||
@@ -37,12 +38,12 @@ describe('deleteCompatibilityAnswers', () => {
|
||||
expect(results.status).toBe('success');
|
||||
expect(mockPg.oneOrNone).toBeCalledTimes(1);
|
||||
expect(mockPg.oneOrNone).toBeCalledWith(
|
||||
expect.stringContaining(`SELECT *`),
|
||||
sqlMatch(`SELECT *`),
|
||||
[mockProps.id, mockAuth.uid]
|
||||
);
|
||||
expect(mockPg.none).toBeCalledTimes(1);
|
||||
expect(mockPg.none).toBeCalledWith(
|
||||
expect.stringContaining('DELETE'),
|
||||
sqlMatch('DELETE'),
|
||||
[mockProps.id, mockAuth.uid]
|
||||
);
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
jest.mock('shared/supabase/init');
|
||||
jest.mock('api/helpers/private-messages');
|
||||
|
||||
import { deleteMessage } from "api/delete-message";
|
||||
import {sqlMatch} from "common/test-utils";
|
||||
import {deleteMessage} from "api/delete-message";
|
||||
import * as supabaseInit from "shared/supabase/init";
|
||||
import * as messageHelpers from "api/helpers/private-messages";
|
||||
import { AuthedUser } from "api/helpers/endpoint";
|
||||
import {AuthedUser} from "api/helpers/endpoint";
|
||||
|
||||
describe('deleteMessage', () => {
|
||||
let mockPg = {} as any;
|
||||
@@ -42,12 +43,12 @@ describe('deleteMessage', () => {
|
||||
|
||||
expect(mockPg.oneOrNone).toBeCalledTimes(1);
|
||||
expect(mockPg.oneOrNone).toBeCalledWith(
|
||||
expect.stringContaining('SELECT *'),
|
||||
sqlMatch('SELECT *'),
|
||||
[mockMessageId.messageId, mockAuth.uid]
|
||||
);
|
||||
expect(mockPg.none).toBeCalledTimes(1);
|
||||
expect(mockPg.none).toBeCalledWith(
|
||||
expect.stringContaining('DELETE'),
|
||||
sqlMatch('DELETE'),
|
||||
[mockMessageId.messageId, mockAuth.uid]
|
||||
);
|
||||
expect(messageHelpers.broadcastPrivateMessages).toBeCalledTimes(1);
|
||||
|
||||
@@ -2,11 +2,12 @@ jest.mock('shared/supabase/init');
|
||||
jest.mock('shared/encryption');
|
||||
jest.mock('api/helpers/private-messages');
|
||||
|
||||
import { editMessage } from "api/edit-message";
|
||||
import {sqlMatch} from "common/test-utils";
|
||||
import {editMessage} from "api/edit-message";
|
||||
import * as supabaseInit from "shared/supabase/init";
|
||||
import * as encryptionModules from "shared/encryption";
|
||||
import * as messageHelpers from "api/helpers/private-messages";
|
||||
import { AuthedUser } from "api/helpers/endpoint";
|
||||
import {AuthedUser} from "api/helpers/endpoint";
|
||||
|
||||
describe('editMessage', () => {
|
||||
let mockPg = {} as any;
|
||||
@@ -54,14 +55,14 @@ describe('editMessage', () => {
|
||||
expect(result.success).toBeTruthy();
|
||||
expect(mockPg.oneOrNone).toBeCalledTimes(1);
|
||||
expect(mockPg.oneOrNone).toBeCalledWith(
|
||||
expect.stringContaining('SELECT *'),
|
||||
sqlMatch('SELECT *'),
|
||||
[mockProps.messageId, mockAuth.uid]
|
||||
);
|
||||
expect(encryptionModules.encryptMessage).toBeCalledTimes(1);
|
||||
expect(encryptionModules.encryptMessage).toBeCalledWith(mockPlainTextContent);
|
||||
expect(mockPg.none).toBeCalledTimes(1);
|
||||
expect(mockPg.none).toBeCalledWith(
|
||||
expect.stringContaining('UPDATE private_user_messages'),
|
||||
sqlMatch('UPDATE private_user_messages'),
|
||||
[mockCipher, mockIV, mockTag, mockProps.messageId]
|
||||
);
|
||||
expect(messageHelpers.broadcastPrivateMessages).toBeCalledTimes(1);
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
jest.mock('shared/supabase/init');
|
||||
jest.mock('common/util/try-catch');
|
||||
|
||||
import { getOptions } from "api/get-options";
|
||||
import {sqlMatch} from "common/test-utils";
|
||||
import {getOptions} from "api/get-options";
|
||||
import * as supabaseInit from "shared/supabase/init";
|
||||
import { tryCatch } from "common/util/try-catch";
|
||||
import { AuthedUser } from "api/helpers/endpoint";
|
||||
import {tryCatch} from "common/util/try-catch";
|
||||
import {AuthedUser} from "api/helpers/endpoint";
|
||||
|
||||
describe('getOptions', () => {
|
||||
let mockPg = {} as any;
|
||||
@@ -38,7 +39,7 @@ describe('getOptions', () => {
|
||||
expect(result.names).toContain(mockData[0].name);
|
||||
expect(mockPg.manyOrNone).toBeCalledTimes(1);
|
||||
expect(mockPg.manyOrNone).toBeCalledWith(
|
||||
expect.stringContaining('SELECT interests.name')
|
||||
sqlMatch('SELECT interests.name')
|
||||
);
|
||||
expect(tryCatch).toBeCalledTimes(1);
|
||||
});
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
jest.mock('shared/supabase/init');
|
||||
jest.mock('shared/compatibility/compute-scores');
|
||||
|
||||
import { setCompatibilityAnswer } from "api/set-compatibility-answer";
|
||||
import {sqlMatch} from "common/test-utils";
|
||||
import {setCompatibilityAnswer} from "api/set-compatibility-answer";
|
||||
import * as supabaseInit from "shared/supabase/init";
|
||||
import { recomputeCompatibilityScoresForUser } from "shared/compatibility/compute-scores";
|
||||
import { AuthedUser } from "api/helpers/endpoint";
|
||||
import {recomputeCompatibilityScoresForUser} from "shared/compatibility/compute-scores";
|
||||
import {AuthedUser} from "api/helpers/endpoint";
|
||||
|
||||
describe('setCompatibilityAnswer', () => {
|
||||
let mockPg = {} as any;
|
||||
@@ -53,7 +54,7 @@ describe('setCompatibilityAnswer', () => {
|
||||
expect(mockPg.one).toBeCalledTimes(1);
|
||||
expect(mockPg.one).toBeCalledWith(
|
||||
{
|
||||
text: expect.stringContaining('INSERT INTO compatibility_answers'),
|
||||
text: sqlMatch('INSERT INTO compatibility_answers'),
|
||||
values: [
|
||||
mockAuth.uid,
|
||||
mockProps.questionId,
|
||||
|
||||
@@ -105,7 +105,7 @@ describe('updateMe', () => {
|
||||
);
|
||||
expect(mockPg.oneOrNone).toBeCalledTimes(1);
|
||||
expect(mockPg.oneOrNone).toBeCalledWith(
|
||||
expect.stringContaining('update users'),
|
||||
sqlMatch('update users'),
|
||||
{
|
||||
adds: expect.any(Object),
|
||||
removes: expect.any(Array),
|
||||
|
||||
@@ -2,8 +2,9 @@ jest.mock('shared/supabase/init');
|
||||
jest.mock('shared/supabase/users');
|
||||
jest.mock('shared/websockets/helpers');
|
||||
|
||||
import { AuthedUser } from "api/helpers/endpoint";
|
||||
import { updateNotifSettings } from "api/update-notif-setting";
|
||||
import {sqlMatch} from "common/test-utils";
|
||||
import {AuthedUser} from "api/helpers/endpoint";
|
||||
import {updateNotifSettings} from "api/update-notif-setting";
|
||||
import * as supabaseInit from "shared/supabase/init";
|
||||
import * as supabaseUsers from "shared/supabase/users";
|
||||
import * as websocketHelpers from "shared/websockets/helpers";
|
||||
@@ -40,7 +41,7 @@ describe('updateNotifSettings', () => {
|
||||
|
||||
expect(mockPg.none).toBeCalledTimes(1);
|
||||
expect(mockPg.none).toBeCalledWith(
|
||||
expect.stringContaining('update private_users'),
|
||||
sqlMatch('update private_users'),
|
||||
[mockProps.type, mockProps.medium, mockAuth.uid]
|
||||
);
|
||||
expect(websocketHelpers.broadcastUpdatedPrivateUser).toBeCalledTimes(1);
|
||||
|
||||
Reference in New Issue
Block a user