gongxiangp2/lib/__tests__/dingtalk-oauth.test.ts
2026-07-07 09:31:46 +08:00

33 lines
869 B
TypeScript

/** @jest-environment node */
describe('dingtalk oauth helpers', () => {
const originalEnv = process.env
beforeEach(() => {
jest.resetModules()
process.env = {
...originalEnv,
NEXT_PUBLIC_APP_URL: 'https://sc.jiansun.vip',
}
})
afterEach(() => {
process.env = originalEnv
jest.restoreAllMocks()
})
test('buildDingtalkOAuthUrl 支持覆盖 client_id', async () => {
process.env.DINGTALK_CLIENT_ID = 'login-client-id'
const { buildDingtalkOAuthUrl } = await import('@/lib/dingtalk-oauth')
const url = new URL(buildDingtalkOAuthUrl({
redirectPath: '/performance-survey',
clientId: 'notice-client-id',
source: 'work_notice_direct',
}))
expect(url.searchParams.get('client_id')).toBe('notice-client-id')
expect(url.searchParams.get('client_id')).not.toBe('login-client-id')
})
})