mirror of
https://github.com/Cccc-owo/CheckInApp.git
synced 2026-06-17 14:06:28 +00:00
feat(frontend): show user credential expiry
This commit is contained in:
@@ -4,6 +4,7 @@ import type { TokenStatus } from '@/api'
|
||||
import {
|
||||
canRefreshAuthorization,
|
||||
formatAuthorizationExpiryTooltip,
|
||||
formatUserAuthorizationSummary,
|
||||
formatRemainingDays,
|
||||
} from './dashboard-license.ts'
|
||||
|
||||
@@ -65,3 +66,22 @@ test('formats remaining days label consistently', () => {
|
||||
assert.equal(formatRemainingDays(0), '0 天')
|
||||
assert.equal(formatRemainingDays(12), '12 天')
|
||||
})
|
||||
|
||||
test('formats user authorization summary from jwt expiration', () => {
|
||||
assert.deepEqual(formatUserAuthorizationSummary('0'), {
|
||||
label: '未绑定凭证',
|
||||
tone: 'neutral',
|
||||
})
|
||||
assert.deepEqual(formatUserAuthorizationSummary('1000', 2000), {
|
||||
label: '凭证过期',
|
||||
tone: 'danger',
|
||||
})
|
||||
assert.deepEqual(formatUserAuthorizationSummary(String(2000 + 2 * 24 * 60 * 60), 2000), {
|
||||
label: '2 天后过期',
|
||||
tone: 'warning',
|
||||
})
|
||||
assert.deepEqual(formatUserAuthorizationSummary(String(2000 + 9 * 24 * 60 * 60), 2000), {
|
||||
label: '9 天后过期',
|
||||
tone: 'success',
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user