chore: remove GitHub Actions workflows, use Woodpecker CI exclusively
This commit is contained in:
1 parent
0a1adfc2a2
commit
e8dffa4f05
82 files changed
+19565
-101
No files matched your search
@@ -0,0 +1,154 @@
|
||||
import { describe, it, expect } from '@jest/globals';
|
||||
|
||||
jest.mock('next-auth', () => {
|
||||
const mockNextAuth = jest.fn(() => ({
|
||||
handlers: {
|
||||
authOptions: {
|
||||
providers: [
|
||||
{
|
||||
name: '邮箱密码',
|
||||
credentials: {
|
||||
email: { label: '邮箱', type: 'email' },
|
||||
password: { label: '密码', type: 'password' },
|
||||
},
|
||||
},
|
||||
],
|
||||
callbacks: {
|
||||
jwt: jest.fn(),
|
||||
session: jest.fn(),
|
||||
},
|
||||
pages: {
|
||||
signIn: '/admin/login',
|
||||
error: '/admin/login',
|
||||
},
|
||||
session: {
|
||||
strategy: 'jwt',
|
||||
},
|
||||
},
|
||||
},
|
||||
signIn: jest.fn(),
|
||||
signOut: jest.fn(),
|
||||
auth: jest.fn(),
|
||||
}));
|
||||
|
||||
return {
|
||||
__esModule: true,
|
||||
default: mockNextAuth,
|
||||
};
|
||||
});
|
||||
|
||||
jest.mock('next-auth/providers/credentials', () => {
|
||||
return jest.fn(() => ({
|
||||
name: '邮箱密码',
|
||||
credentials: {
|
||||
email: { label: '邮箱', type: 'email' },
|
||||
password: { label: '密码', type: 'password' },
|
||||
},
|
||||
}));
|
||||
});
|
||||
|
||||
jest.mock('@/db', () => ({
|
||||
db: {
|
||||
select: jest.fn().mockReturnThis(),
|
||||
from: jest.fn().mockReturnThis(),
|
||||
where: jest.fn().mockReturnThis(),
|
||||
limit: jest.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
jest.mock('bcryptjs', () => ({
|
||||
default: {
|
||||
compare: jest.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
describe('Auth Module Configuration', () => {
|
||||
describe('Provider Configuration', () => {
|
||||
it('should export handlers', async () => {
|
||||
const auth = await import('./auth');
|
||||
expect(auth).toHaveProperty('handlers');
|
||||
});
|
||||
|
||||
it('should export signIn function', async () => {
|
||||
const auth = await import('./auth');
|
||||
expect(auth).toHaveProperty('signIn');
|
||||
expect(typeof auth.signIn).toBe('function');
|
||||
});
|
||||
|
||||
it('should export signOut function', async () => {
|
||||
const auth = await import('./auth');
|
||||
expect(auth).toHaveProperty('signOut');
|
||||
expect(typeof auth.signOut).toBe('function');
|
||||
});
|
||||
|
||||
it('should export auth function', async () => {
|
||||
const auth = await import('./auth');
|
||||
expect(auth).toHaveProperty('auth');
|
||||
expect(typeof auth.auth).toBe('function');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Auth Options', () => {
|
||||
it('should have authOptions in handlers', async () => {
|
||||
const { handlers } = await import('./auth');
|
||||
expect(handlers).toHaveProperty('authOptions');
|
||||
});
|
||||
|
||||
it('should have providers configured', async () => {
|
||||
const { handlers } = await import('./auth');
|
||||
expect(handlers.authOptions).toHaveProperty('providers');
|
||||
expect(Array.isArray(handlers.authOptions.providers)).toBe(true);
|
||||
});
|
||||
|
||||
it('should have correct provider name', async () => {
|
||||
const { handlers } = await import('./auth');
|
||||
const provider = handlers.authOptions.providers[0];
|
||||
expect(provider.name).toBe('邮箱密码');
|
||||
});
|
||||
|
||||
it('should have email credential', async () => {
|
||||
const { handlers } = await import('./auth');
|
||||
const provider = handlers.authOptions.providers[0];
|
||||
expect(provider.credentials).toHaveProperty('email');
|
||||
});
|
||||
|
||||
it('should have password credential', async () => {
|
||||
const { handlers } = await import('./auth');
|
||||
const provider = handlers.authOptions.providers[0];
|
||||
expect(provider.credentials).toHaveProperty('password');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Page Configuration', () => {
|
||||
it('should have correct sign-in page', async () => {
|
||||
const { handlers } = await import('./auth');
|
||||
expect(handlers.authOptions.pages.signIn).toBe('/admin/login');
|
||||
});
|
||||
|
||||
it('should have correct error page', async () => {
|
||||
const { handlers } = await import('./auth');
|
||||
expect(handlers.authOptions.pages.error).toBe('/admin/login');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Session Configuration', () => {
|
||||
it('should use JWT session strategy', async () => {
|
||||
const { handlers } = await import('./auth');
|
||||
expect(handlers.authOptions.session.strategy).toBe('jwt');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Callbacks', () => {
|
||||
it('should have jwt callback', async () => {
|
||||
const { handlers } = await import('./auth');
|
||||
expect(handlers.authOptions.callbacks).toHaveProperty('jwt');
|
||||
expect(typeof handlers.authOptions.callbacks.jwt).toBe('function');
|
||||
});
|
||||
|
||||
it('should have session callback', async () => {
|
||||
const { handlers } = await import('./auth');
|
||||
expect(handlers.authOptions.callbacks).toHaveProperty('session');
|
||||
expect(typeof handlers.authOptions.callbacks.session).toBe('function');
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user