mirror of
https://github.com/langgenius/dify.git
synced 2026-10-04 13:47:55 +08:00
Co-authored-by: Joel <iamjoel007@gmail.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
43 lines
1006 B
TypeScript
43 lines
1006 B
TypeScript
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
import { sendEMailLoginCode } from './common'
|
|
|
|
const mocks = vi.hoisted(() => ({
|
|
post: vi.fn(),
|
|
}))
|
|
|
|
vi.mock('./base', () => ({
|
|
del: vi.fn(),
|
|
get: vi.fn(),
|
|
patch: vi.fn(),
|
|
post: mocks.post,
|
|
}))
|
|
|
|
describe('sendEMailLoginCode', () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks()
|
|
})
|
|
|
|
it('includes the Turnstile token when provided', async () => {
|
|
await sendEMailLoginCode('user@example.com', 'en-US', 'turnstile-token')
|
|
|
|
expect(mocks.post).toHaveBeenCalledWith('/email-code-login', {
|
|
body: {
|
|
email: 'user@example.com',
|
|
language: 'en-US',
|
|
turnstile_token: 'turnstile-token',
|
|
},
|
|
})
|
|
})
|
|
|
|
it('omits the Turnstile token when it is not provided', async () => {
|
|
await sendEMailLoginCode('user@example.com', 'en-US')
|
|
|
|
expect(mocks.post).toHaveBeenCalledWith('/email-code-login', {
|
|
body: {
|
|
email: 'user@example.com',
|
|
language: 'en-US',
|
|
},
|
|
})
|
|
})
|
|
})
|