feat: 将 Sense 登录有效期调整为30天 (#104)
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import Cookies from 'js-cookie'
|
||||
import { getToken, removeToken, setToken } from '@/utils/auth'
|
||||
|
||||
jest.mock('js-cookie', () => ({
|
||||
get: jest.fn(),
|
||||
set: jest.fn(),
|
||||
remove: jest.fn()
|
||||
}))
|
||||
|
||||
describe('Sense login token cookie', () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks()
|
||||
})
|
||||
|
||||
it('persists the token for 30 days', () => {
|
||||
setToken('test-token')
|
||||
|
||||
expect(Cookies.set).toHaveBeenCalledWith(
|
||||
'Sense-Admin-Token',
|
||||
'test-token',
|
||||
{ expires: 30 }
|
||||
)
|
||||
})
|
||||
|
||||
it('reads and removes the same product-specific cookie', () => {
|
||||
getToken()
|
||||
removeToken()
|
||||
|
||||
expect(Cookies.get).toHaveBeenCalledWith('Sense-Admin-Token')
|
||||
expect(Cookies.remove).toHaveBeenCalledWith('Sense-Admin-Token')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user