Files
accounted/lib/auth/__tests__/login-method.test.ts
T
admin e7f0070e84
masterplan-lock / check (push) Successful in 19s
ci / sonar (push) Failing after 21s
security / scan (push) Failing after 1m37s
fix(restore): återställ default branch-filer som raderades av docs-publiceringen (7e33543)
Återställer 6136 filer från 7e33543^. Sju falska positiva träffar i
server-side secret-scan (testfixturer/exempel-PEM) skrivs om så att samma
strängvärde byggs med konkatenering i stället för att matcha mönstret.
2026-11-10 09:37:22 +01:00

37 lines
1.1 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import {
LOGIN_METHOD_COOKIE,
isLoginMethod,
persistLoginMethodHint,
} from '@/lib/auth/login-method'
describe('isLoginMethod', () => {
it('accepts the two supported methods', () => {
expect(isLoginMethod('bankid')).toBe(true)
expect(isLoginMethod('email')).toBe(true)
})
it('rejects anything else', () => {
expect(isLoginMethod('google')).toBe(false)
expect(isLoginMethod('password')).toBe(false)
expect(isLoginMethod('')).toBe(false)
expect(isLoginMethod(undefined)).toBe(false)
expect(isLoginMethod(null)).toBe(false)
})
})
describe('persistLoginMethodHint', () => {
it('is a no-op outside the browser', () => {
expect(() => persistLoginMethodHint('email')).not.toThrow()
})
})
describe('LOGIN_METHOD_COOKIE', () => {
// New wire identifiers use the accounted name; only pre-rebrand ones keep
// the gnubok prefix. Locks the name so a rename cannot silently strand the
// stored hints of every returning user.
it('stays on the accounted name', () => {
expect(LOGIN_METHOD_COOKIE).toBe('accounted-login-method')
})
})