750aa40e8e
Reviewed-on: #355 Co-authored-by: miteruzo <miteruzo@naver.com> Co-committed-by: miteruzo <miteruzo@naver.com>
21 行
675 B
TypeScript
21 行
675 B
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { canEditContent } from '@/lib/users'
|
|
|
|
import type { UserRole } from '@/types'
|
|
|
|
const userWithRole = (role: UserRole) => ({ role })
|
|
|
|
describe ('user permission helpers', () => {
|
|
it ('allows admins and members to edit content', () => {
|
|
expect (canEditContent (userWithRole ('admin'))).toBe (true)
|
|
expect (canEditContent (userWithRole ('member'))).toBe (true)
|
|
})
|
|
|
|
it ('does not allow guests or missing users to edit content', () => {
|
|
expect (canEditContent (userWithRole ('guest'))).toBe (false)
|
|
expect (canEditContent (null)).toBe (false)
|
|
expect (canEditContent (undefined)).toBe (false)
|
|
})
|
|
})
|