let { parseTime, $validatePassword, $validateUserName, $t, md5, $d, $fd } = require("./index");


test("时间格式化算法", () => {
    expect(parseTime('2023/10/12', '{y}-{m}-{d} {h}:{i}:{s}')).toBe('2023-10-12 00:00:00')
    expect(parseTime('2023/10/12', '{y}-{m}-{d} {h}:{i}')).toBe('2023-10-12 00:00')
    expect(parseTime('2023/10/12', '{y}-{m}-{d} {h}')).toBe('2023-10-12 00')
    expect(parseTime('2023/10/12', '{y}-{m}-{d}')).toBe('2023-10-12')
})

test("验证密码复杂度算法", () => {
    expect($validatePassword('1qaz@WSXCVB')).toBe(true)
    expect($validatePassword('1qazWSXCVB')).toBe(false)
    expect($validatePassword('qaz@WSXCVB')).toBe(false)
    expect($validatePassword('1qaz@wsxcvb')).toBe(false)
})

test("验证用户名复杂度算法", () => {
    expect($validateUserName('abcd')).toBe(true)
    expect($validateUserName('abc')).toBe(false)
    expect($validateUserName('ab12')).toBe(true)
    expect($validateUserName('abcdefghyjklmnopq')).toBe(false)
})

test("获取国际化", () => {
    expect($t('trials:trials-panel:readingTracking')).toBe('阅片跟踪')
})


test("密码md5加密", () => {
    expect(md5('123456')).toBe('e10adc3949ba59abbe56e057f20f883e')
})

test("获取字典", () => {
    expect($d()).toBe(true)
})

test("获取制定字典label", () => {
    expect($fd('YesOrNo', 'true')).toBe('是')
    expect($fd('YesOrNo', 'false')).toBe('否')
    expect($fd('IsEnable', 'true')).toBe('启用')
    expect($fd('ReuploadEnum', '1')).toBe('CRC申请重传')
})
