53 lines
1.5 KiB
TypeScript
53 lines
1.5 KiB
TypeScript
import { EMPLOYMENT_STATE, resolveEmploymentState } from '@/lib/employment-state'
|
|
|
|
describe('resolveEmploymentState', () => {
|
|
it('marks an HR roster resignation as resigned even without a registered status code', () => {
|
|
expect(
|
|
resolveEmploymentState({
|
|
hasResignationRecord: false,
|
|
rawEmploymentStatus: '离职',
|
|
registeredStatusCode: null,
|
|
}),
|
|
).toBe(EMPLOYMENT_STATE.RESIGNED)
|
|
})
|
|
|
|
it('lets an explicit resignation override an active registered status code', () => {
|
|
expect(
|
|
resolveEmploymentState({
|
|
hasResignationRecord: false,
|
|
rawEmploymentStatus: '已离职',
|
|
registeredStatusCode: 3,
|
|
}),
|
|
).toBe(EMPLOYMENT_STATE.RESIGNED)
|
|
})
|
|
|
|
it('supports the numeric resigned status stored as raw text', () => {
|
|
expect(
|
|
resolveEmploymentState({
|
|
hasResignationRecord: false,
|
|
rawEmploymentStatus: '5',
|
|
}),
|
|
).toBe(EMPLOYMENT_STATE.RESIGNED)
|
|
})
|
|
|
|
it('keeps active registered status codes active when no resignation evidence exists', () => {
|
|
expect(
|
|
resolveEmploymentState({
|
|
hasResignationRecord: false,
|
|
rawEmploymentStatus: null,
|
|
registeredStatusCode: 2,
|
|
}),
|
|
).toBe(EMPLOYMENT_STATE.ACTIVE)
|
|
})
|
|
|
|
it('keeps missing and ambiguous signals unknown', () => {
|
|
expect(
|
|
resolveEmploymentState({
|
|
hasResignationRecord: false,
|
|
rawEmploymentStatus: '待确认',
|
|
registeredStatusCode: null,
|
|
}),
|
|
).toBe(EMPLOYMENT_STATE.UNKNOWN)
|
|
})
|
|
})
|