Skip to content

Commit

Permalink
Changes path for tests to shared folder instead of utils
Browse files Browse the repository at this point in the history
  • Loading branch information
KSJaay committed Jun 19, 2024
1 parent 72860ae commit 2916b39
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions test/server/middleware/auth/login.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { beforeEach, describe, it, vi } from 'vitest';
import { createRequest, createResponse } from 'node-mocks-http';
import SQLite from '../../../../server/database/sqlite/setup';
import login from '../../../../server/middleware/auth/login';
import { setServerSideCookie } from '../../../../server/utils/cookies';
import { setServerSideCookie } from '../../../../shared/utils/cookies';
import { signInUser } from '../../../../server/database/queries/user';

vi.mock('../../../../server/database/sqlite/setup');
vi.mock('../../../../server/database/queries/user');
vi.mock('../../../../server/utils/cookies');
vi.mock('../../../../shared/utils/cookies');

describe('Login - Middleware', () => {
const user = {
Expand Down
6 changes: 3 additions & 3 deletions test/server/middleware/auth/logout.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { createRequest, createResponse } from 'node-mocks-http';
import { deleteCookie } from '../../../../server/utils/cookies';
import { deleteCookie } from '../../../../shared/utils/cookies';
import logout from '../../../../server/middleware/auth/logout';
import { createURL } from '../../../../server/utils/url';
import { createURL } from '../../../../shared/utils/url';

vi.mock('../../../../server/utils/cookies');
vi.mock('../../../../shared/utils/cookies');

describe('Logout - Middleware', () => {
let fakeRequest;
Expand Down
4 changes: 2 additions & 2 deletions test/server/middleware/auth/register.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import {
fetchMembers,
registerUser,
} from '../../../../server/database/queries/user';
import { setServerSideCookie } from '../../../../server/utils/cookies';
import { setServerSideCookie } from '../../../../shared/utils/cookies';

vi.mock('../../../../server/database/queries/user');
vi.mock('../../../../server/utils/cookies');
vi.mock('../../../../shared/utils/cookies');

describe('Register - Middleware', () => {
let fakeRequest;
Expand Down
4 changes: 2 additions & 2 deletions test/server/middleware/authorization.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { createRequest, createResponse } from 'node-mocks-http';
import { afterEach, beforeEach, describe, it, vi } from 'vitest';
import { userExists } from '../../../server/database/queries/user';
import authorization from '../../../server/middleware/authorization';
import { deleteCookie } from '../../../server/utils/cookies';
import { deleteCookie } from '../../../shared/utils/cookies';

vi.mock('../../../server/database/queries/user');
vi.mock('../../../server/utils/cookies');
vi.mock('../../../shared/utils/cookies');

describe('Authorization - Middleware', () => {
let fakeRequest;
Expand Down
2 changes: 1 addition & 1 deletion test/server/middleware/user/access/approve.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { beforeEach, describe, expect, it, vi } from 'vitest';
import { createRequest, createResponse } from 'node-mocks-http';
import { approveAccess } from '../../../../../server/database/queries/user';
import accessApproveMiddleware from '../../../../../server/middleware/user/access/approveUser';
import { AuthorizationError } from '../../../../../server/utils/errors';
import { AuthorizationError } from '../../../../../shared/utils/errors';

vi.mock('../../../../../server/database/queries/user');

Expand Down
2 changes: 1 addition & 1 deletion test/server/middleware/user/access/decline.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { createRequest, createResponse } from 'node-mocks-http';
import { declineAccess } from '../../../../../server/database/queries/user';
import { AuthorizationError } from '../../../../../server/utils/errors';
import { AuthorizationError } from '../../../../../shared/utils/errors';
import accessDeclineMiddleware from '../../../../../server/middleware/user/access/declineUser';

vi.mock('../../../../../server/database/queries/user');
Expand Down
2 changes: 1 addition & 1 deletion test/server/middleware/user/access/removeUser.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { createRequest, createResponse } from 'node-mocks-http';
import { declineAccess } from '../../../../../server/database/queries/user';
import { AuthorizationError } from '../../../../../server/utils/errors';
import { AuthorizationError } from '../../../../../shared/utils/errors';
import accessRemoveMiddleware from '../../../../../server/middleware/user/access/removeUser';

vi.mock('../../../../../server/database/queries/user');
Expand Down
2 changes: 1 addition & 1 deletion test/server/middleware/user/permission/update.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
userExists,
} from '../../../../../server/database/queries/user';
import permissionUpdateMiddleware from '../../../../../server/middleware/user/permission/update';
import { AuthorizationError } from '../../../../../server/utils/errors';
import { AuthorizationError } from '../../../../../shared/utils/errors';

vi.mock('../../../../../server/database/queries/user');

Expand Down
4 changes: 2 additions & 2 deletions test/server/middleware/user/update/avatar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import {
userExists,
} from '../../../../../server/database/queries/user';
import userUpdateAvatar from '../../../../../server/middleware/user/update/avatar';
import validators from '../../../../../server/utils/validators';
import validators from '../../../../../shared/validators';

vi.mock('../../../../../server/database/queries/user');
vi.mock('../../../../../server/utils/validators');
vi.mock('../../../../../shared/validators');

describe('userUpdateAvatar - Middleware', () => {
const user = {
Expand Down
4 changes: 2 additions & 2 deletions test/server/middleware/user/update/password.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import {
userExists,
} from '../../../../../server/database/queries/user';
import userUpdatePassword from '../../../../../server/middleware/user/update/password';
import { verifyPassword } from '../../../../../server/utils/hashPassword';
import { verifyPassword } from '../../../../../shared/utils/hashPassword';

vi.mock('../../../../../server/database/queries/user');
vi.mock('../../../../../server/utils/hashPassword');
vi.mock('../../../../../shared/utils/hashPassword');

describe('userUpdatePassword - Middleware', () => {
const user = {
Expand Down
4 changes: 2 additions & 2 deletions test/server/middleware/user/update/username.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import {
userExists,
} from '../../../../../server/database/queries/user';
import userUpdateUsername from '../../../../../server/middleware/user/update/username';
import validators from '../../../../../server/utils/validators';
import validators from '../../../../../shared/validators';

vi.mock('../../../../../server/database/queries/user');
vi.mock('../../../../../server/utils/validators');
vi.mock('../../../../../shared/validators');

describe('userUpdateUsername - Middleware', () => {
const user = {
Expand Down
4 changes: 2 additions & 2 deletions test/shared/setupDatabase.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import fs from 'fs';

// import local files
import { SQLite } from '../../server/database/sqlite/setup.js';
import { generateHash } from '../../server/utils/hashPassword.js';
import logger from '../../server/utils/logger.js';
import { generateHash } from '../../shared/utils/hashPassword.js';
import logger from '../../shared/utils/logger.js';
import { loadJSON } from '../../shared/parseJson.js';

const loginDetails = loadJSON('../test/e2e/setup/fixtures/login.json');
Expand Down

0 comments on commit 2916b39

Please sign in to comment.