Skip to content

Commit 7f5209d

Browse files
authored
Move tests inline (#304)
* move tests inline * remove other references to __tests__
1 parent 962b835 commit 7f5209d

20 files changed

+96
-96
lines changed

jest.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const config: Config = {
2626
{
2727
displayName: 'jsdom',
2828
testEnvironment: 'jsdom',
29-
testMatch: ['**/__tests__/**/*.spec.tsx'],
29+
testMatch: ['**/src/**/*.spec.tsx'],
3030
transform: {
3131
'^.+\\.tsx?$': 'ts-jest', // Use ts-jest for TypeScript files
3232
},
@@ -37,7 +37,7 @@ const config: Config = {
3737
{
3838
displayName: 'node',
3939
testEnvironment: 'node',
40-
testMatch: ['**/__tests__/**/*.spec.ts'],
40+
testMatch: ['**/src/**/*.spec.ts'],
4141
transform: {
4242
'^.+\\.tsx?$': 'ts-jest',
4343
},

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@
3030
"lint": "eslint \"src/**/*.ts*\"",
3131
"test": "jest",
3232
"test:watch": "jest --watch",
33-
"prettier": "prettier \"{src,__tests__}/**/*.{js,ts,tsx}\" --check",
34-
"format": "prettier \"{src,__tests__}/**/*.{js,ts,tsx}\" --write"
33+
"prettier": "prettier \"src/**/*.{js,ts,tsx}\" --check",
34+
"format": "prettier \"src/**/*.{js,ts,tsx}\" --write",
35+
"type-check": "tsc --project tsconfig.json --noEmit"
3536
},
3637
"dependencies": {
3738
"@workos-inc/node": "^7.67.0",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
getAccessTokenAction,
99
refreshAccessTokenAction,
1010
} from '../src/actions.js';
11-
import { signOut, switchToOrganization } from '../src/auth.js';
11+
import { signOut, switchToOrganization } from './auth.js';
1212
import { getWorkOS } from '../src/workos.js';
1313
import { withAuth, refreshSession } from '../src/session.js';
1414

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { describe, it, expect, beforeEach, jest } from '@jest/globals';
22

3-
import { getSignInUrl, getSignUpUrl, signOut, switchToOrganization } from '../src/auth.js';
4-
import * as session from '../src/session.js';
3+
import { getSignInUrl, getSignUpUrl, signOut, switchToOrganization } from './auth.js';
4+
import * as session from './session.js';
55
import * as cache from 'next/cache';
6-
import * as workosModule from '../src/workos.js';
6+
import * as workosModule from './workos.js';
77

88
// These are mocked in jest.setup.ts
99
import { cookies, headers } from 'next/headers';
1010
import { redirect } from 'next/navigation';
1111
import { generateSession, generateTestToken } from './test-helpers.js';
1212
import { sealData } from 'iron-session';
13-
import { getWorkOS } from '../src/workos.js';
13+
import { getWorkOS } from './workos.js';
1414

1515
const workos = getWorkOS();
1616

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { getWorkOS } from '../src/workos.js';
2-
import { handleAuth } from '../src/authkit-callback-route.js';
1+
import { getWorkOS } from './workos.js';
2+
import { handleAuth } from './authkit-callback-route.js';
33
import { NextRequest, NextResponse } from 'next/server';
44

55
// Mocked in jest.setup.ts
@@ -119,7 +119,7 @@ describe('authkit-callback-route', () => {
119119
request.nextUrl.searchParams.set('code', 'invalid-code');
120120

121121
const handler = handleAuth({
122-
onError: ({ error }) => {
122+
onError: () => {
123123
return new Response(JSON.stringify({ error: { message: 'Custom error' } }), {
124124
status: 500,
125125
headers: { 'Content-Type': 'application/json' },
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import React from 'react';
22
import { render, waitFor, act } from '@testing-library/react';
33
import '@testing-library/jest-dom';
4-
import { AuthKitProvider, useAuth } from '../src/components/authkit-provider.js';
4+
import { AuthKitProvider, useAuth } from './authkit-provider.js';
55
import {
66
checkSessionAction,
77
getAuthAction,
88
refreshAuthAction,
99
handleSignOutAction,
1010
switchToOrganizationAction,
11-
} from '../src/actions.js';
11+
} from '../actions.js';
1212

13-
jest.mock('../src/actions', () => ({
13+
jest.mock('../actions', () => ({
1414
checkSessionAction: jest.fn(),
1515
getAuthAction: jest.fn(),
1616
refreshAuthAction: jest.fn(),
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import { render } from '@testing-library/react';
33
import '@testing-library/jest-dom';
4-
import { Button } from '../src/components/button.js';
4+
import { Button } from './button.js';
55

66
describe('Button', () => {
77
it('should render with default props', () => {
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import { render, act, screen } from '@testing-library/react';
22
import '@testing-library/jest-dom';
3-
import { Impersonation } from '../src/components/impersonation.js';
4-
import { useAuth } from '../src/components/authkit-provider.js';
5-
import { getOrganizationAction } from '../src/actions.js';
3+
import { Impersonation } from './impersonation.js';
4+
import { useAuth } from './authkit-provider.js';
5+
import { getOrganizationAction } from '../actions.js';
66
import * as React from 'react';
7-
import { handleSignOutAction } from '../src/actions.js';
7+
import { handleSignOutAction } from '../actions.js';
88

99
// Mock the useAuth hook
10-
jest.mock('../src/components/authkit-provider', () => ({
10+
jest.mock('./authkit-provider', () => ({
1111
useAuth: jest.fn(),
1212
}));
1313

1414
// Mock the getOrganizationAction
15-
jest.mock('../src/actions', () => ({
15+
jest.mock('../actions', () => ({
1616
getOrganizationAction: jest.fn(),
1717
handleSignOutAction: jest.fn(),
1818
}));
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { render, act } from '@testing-library/react';
2-
import { MinMaxButton } from '../src/components/min-max-button.js';
2+
import { MinMaxButton } from './min-max-button.js';
33
import * as React from 'react';
44
import '@testing-library/jest-dom';
55

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { tokenStore, TokenStore } from '../src/components/tokenStore.js';
2-
import { getAccessTokenAction, refreshAccessTokenAction } from '../src/actions.js';
1+
import { tokenStore, TokenStore } from './tokenStore.js';
2+
import { getAccessTokenAction, refreshAccessTokenAction } from '../actions.js';
33

4-
jest.mock('../src/actions.js', () => ({
4+
jest.mock('../actions.js', () => ({
55
getAccessTokenAction: jest.fn(),
66
refreshAccessTokenAction: jest.fn(),
77
}));

0 commit comments

Comments
 (0)