Skip to content

Commit

Permalink
refactor: remove js cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
pyphilia committed Oct 31, 2023
1 parent a45af1f commit 7dc46e2
Show file tree
Hide file tree
Showing 35 changed files with 34 additions and 135 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"@trivago/prettier-plugin-sort-imports": "4.2.1",
"@types/crypto-js": "4.1.3",
"@types/jest": "29.5.6",
"@types/js-cookie": "3.0.5",
"@types/jsdom": "21.1.4",
"@types/node": "20.8.8",
"@types/qs": "6.9.9",
Expand All @@ -62,7 +61,6 @@
"husky": "8.0.3",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"js-cookie": "3.0.5",
"mock-socket": "9.3.1",
"nock": "13.3.6",
"prettier": "3.0",
Expand Down
2 changes: 0 additions & 2 deletions src/hooks/action.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
} from '@graasp/sdk';

import { StatusCodes } from 'http-status-codes';
import Cookies from 'js-cookie';
import nock from 'nock';

import {
Expand All @@ -30,7 +29,6 @@ type AggregateActionsResponse = {
const { hooks, wrapper, queryClient } = setUpTest();
const itemId = ITEMS[0].id;

jest.spyOn(Cookies, 'get').mockReturnValue({ session: 'somesession' });
describe('Action Hooks', () => {
afterEach(() => {
nock.cleanAll();
Expand Down
2 changes: 0 additions & 2 deletions src/hooks/apps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { App } from '@graasp/sdk';

import { StatusCodes } from 'http-status-codes';
import Cookies from 'js-cookie';
import nock from 'nock';

import { APPS, UNAUTHORIZED_RESPONSE } from '../../test/constants';
Expand All @@ -12,7 +11,6 @@ import { APPS_KEY } from '../config/keys';

const { hooks, wrapper, queryClient } = setUpTest();

jest.spyOn(Cookies, 'get').mockReturnValue({ session: 'somesession' });
describe('Apps Hooks', () => {
afterEach(() => {
nock.cleanAll();
Expand Down
3 changes: 0 additions & 3 deletions src/hooks/category.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable import/no-extraneous-dependencies */
import { StatusCodes } from 'http-status-codes';
import Cookies from 'js-cookie';
import nock from 'nock';

import {
Expand All @@ -24,8 +23,6 @@ import {

const { hooks, wrapper, queryClient } = setUpTest();

jest.spyOn(Cookies, 'get').mockReturnValue({ session: 'somesession' });

describe('Category Hooks', () => {
afterEach(() => {
nock.cleanAll();
Expand Down
14 changes: 5 additions & 9 deletions src/hooks/chat.test.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
/* eslint-disable import/no-extraneous-dependencies */
import { ChatMessage, ItemChat } from '@graasp/sdk';
import { ChatMessage } from '@graasp/sdk';

import { StatusCodes } from 'http-status-codes';
import Cookies from 'js-cookie';
import nock from 'nock';

import {
ITEMS,
MOCK_ITEM,
MOCK_MEMBER,
UNAUTHORIZED_RESPONSE,
createMockItemChat,
} from '../../test/constants';
import { mockHook, setUpTest } from '../../test/utils';
import { buildGetItemChatRoute } from '../api/routes';
import { buildItemChatKey } from '../config/keys';

const { hooks, wrapper, queryClient } = setUpTest();

jest.spyOn(Cookies, 'get').mockReturnValue({ session: 'somesession' });

describe('Chat Hooks', () => {
afterEach(() => {
nock.cleanAll();
queryClient.clear();
});

describe('useItemChat', () => {
const itemId = ITEMS_JS[0].id;
const itemId = ITEMS[0].id;
const mockMessage: ChatMessage = {
id: 'some-messageId',
item: MOCK_ITEM,
Expand All @@ -42,7 +38,7 @@ describe('Chat Hooks', () => {
const hook = () => hooks.useItemChat(itemId);

it(`Receive chat messages`, async () => {
const response: ItemChat = createMockItemChat([mockMessage]);
const response = [mockMessage];
const endpoints = [
{
route,
Expand Down Expand Up @@ -98,7 +94,7 @@ describe('Chat Hooks', () => {
it(`getUpdates = true`, async () => {
const hook = () => hooks.useItemChat(itemId, { getUpdates: true });

const response = createMockItemChat([mockMessage]);
const response = [mockMessage];
const endpoints = [
{
route,
Expand All @@ -119,7 +115,7 @@ describe('Chat Hooks', () => {

it(`getUpdates = false`, async () => {
const hook = () => hooks.useItemChat(itemId, { getUpdates: false });
const response = createMockItemChat([mockMessage]);
const response = [mockMessage];
const endpoints = [
{
route,
Expand Down
3 changes: 0 additions & 3 deletions src/hooks/invitation.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* eslint-disable import/no-extraneous-dependencies */
import { StatusCodes } from 'http-status-codes';
import Cookies from 'js-cookie';
import nock from 'nock';

import {
Expand All @@ -18,8 +17,6 @@ import { buildInvitationKey, buildItemInvitationsKey } from '../config/keys';
const { hooks, wrapper, queryClient } = setUpTest();
const item = ITEMS[0];

jest.spyOn(Cookies, 'get').mockReturnValue({ session: 'somesession' });

describe('Invitation Hooks', () => {
afterEach(() => {
nock.cleanAll();
Expand Down
2 changes: 0 additions & 2 deletions src/hooks/item.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
} from '@graasp/sdk';

import { StatusCodes } from 'http-status-codes';
import Cookies from 'js-cookie';
import nock from 'nock';

import {
Expand Down Expand Up @@ -47,7 +46,6 @@ import {
} from '../config/keys';

const { hooks, wrapper, queryClient } = setUpTest();
jest.spyOn(Cookies, 'get').mockReturnValue({ session: 'somesession' });

describe('Items Hooks', () => {
afterEach(() => {
Expand Down
2 changes: 0 additions & 2 deletions src/hooks/itemLike.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ItemLike } from '@graasp/sdk';

import { StatusCodes } from 'http-status-codes';
import Cookies from 'js-cookie';
import nock from 'nock';

import { ITEMS, ITEM_LIKES, UNAUTHORIZED_RESPONSE } from '../../test/constants';
Expand All @@ -16,7 +15,6 @@ import {
} from '../config/keys';

const { hooks, wrapper, queryClient } = setUpTest();
jest.spyOn(Cookies, 'get').mockReturnValue({ session: 'somesession' });

describe('Item Like Hooks', () => {
afterEach(() => {
Expand Down
3 changes: 0 additions & 3 deletions src/hooks/itemTag.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
} from '@graasp/sdk';

import { StatusCodes } from 'http-status-codes';
import Cookies from 'js-cookie';
import nock from 'nock';

import {
Expand All @@ -27,8 +26,6 @@ import { itemTagsKeys } from '../config/keys';

const { hooks, wrapper, queryClient } = setUpTest();

jest.spyOn(Cookies, 'get').mockReturnValue({ session: 'somesession' });

describe('Item Tags Hooks', () => {
afterEach(() => {
nock.cleanAll();
Expand Down
3 changes: 0 additions & 3 deletions src/hooks/itemValidation.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { StatusCodes } from 'http-status-codes';
import Cookies from 'js-cookie';
import nock from 'nock';

import {
Expand All @@ -12,8 +11,6 @@ import { buildLastItemValidationGroupKey } from '../config/keys';

const { hooks, wrapper, queryClient } = setUpTest();

jest.spyOn(Cookies, 'get').mockReturnValue({ session: 'somesession' });

describe('Item Validation Hooks', () => {
afterEach(() => {
nock.cleanAll();
Expand Down
2 changes: 0 additions & 2 deletions src/hooks/member.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
} from '@graasp/sdk';

import { StatusCodes } from 'http-status-codes';
import Cookies from 'js-cookie';
import nock from 'nock';

import {
Expand Down Expand Up @@ -38,7 +37,6 @@ import {
} from '../config/keys';

const { hooks, wrapper, queryClient } = setUpTest();
jest.spyOn(Cookies, 'get').mockReturnValue({ session: 'somesession' });
describe('Member Hooks', () => {
afterEach(() => {
queryClient.clear();
Expand Down
2 changes: 0 additions & 2 deletions src/hooks/membership.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
} from '@graasp/sdk';

import { StatusCodes } from 'http-status-codes';
import Cookies from 'js-cookie';
import nock from 'nock';

import {
Expand All @@ -23,7 +22,6 @@ import {
} from '../config/keys';

const { hooks, wrapper, queryClient } = setUpTest();
jest.spyOn(Cookies, 'get').mockReturnValue({ session: 'somesession' });

describe('Membership Hooks', () => {
afterEach(() => {
Expand Down
3 changes: 0 additions & 3 deletions src/hooks/mention.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable import/no-extraneous-dependencies */
import Cookies from 'js-cookie';
import nock from 'nock';

import { MEMBER_RESPONSE, buildMemberMentions } from '../../test/constants';
Expand All @@ -12,8 +11,6 @@ import { buildMentionKey } from '../config/keys';

const { hooks, wrapper, queryClient } = setUpTest();

jest.spyOn(Cookies, 'get').mockReturnValue({ session: 'somesession' });

describe('Chat Mention Hooks', () => {
afterEach(() => {
nock.cleanAll();
Expand Down
3 changes: 0 additions & 3 deletions src/mutations/action.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { HttpMethod } from '@graasp/sdk';

import { act } from '@testing-library/react';
import { StatusCodes } from 'http-status-codes';
import Cookies from 'js-cookie';
import nock from 'nock';

import {
Expand All @@ -14,8 +13,6 @@ import { mockMutation, setUpTest, waitForMutation } from '../../test/utils';
import { buildExportActions, buildPostItemAction } from '../api/routes';
import { exportActionsRoutine, postActionRoutine } from '../routines';

jest.spyOn(Cookies, 'get').mockReturnValue({ session: 'somesession' });

describe('Action Mutations', () => {
const itemId = ITEMS[0].id;

Expand Down
3 changes: 0 additions & 3 deletions src/mutations/authentication.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { SUCCESS_MESSAGES } from '@graasp/translations';

import { act } from '@testing-library/react';
import { StatusCodes } from 'http-status-codes';
import Cookies from 'js-cookie';
import nock from 'nock';

import { OK_RESPONSE, UNAUTHORIZED_RESPONSE } from '../../test/constants';
Expand Down Expand Up @@ -47,8 +46,6 @@ jest.mock('@graasp/sdk', () => {
};
});

jest.spyOn(Cookies, 'get').mockReturnValue({ session: 'somesession' });

const captcha = 'captcha';
const email = '[email protected]';
const challenge = '1234';
Expand Down
Loading

0 comments on commit 7dc46e2

Please sign in to comment.