import { isEndWithDotNum } from './index'; describe('测试 types 模块 isEndWithDotNum 方法', () => { it('.在数字类型结尾', () => { /** * 该情况理应为 true,但由于 123. 传递给函数时会自动转换为 123,所以导致正则匹配失败,返回了false */ expect(isEndWithDotNum(123)).toBe(false); }); it('.在数字中间位置', () => { expect(isEndWithDotNum(12.3)).toBe(false); }); it('.在数字开头', () => { expect(isEndWithDotNum(0.123)).toBe(false); }); it('.在数字类型字符串结尾', () => { expect(isEndWithDotNum('123.')).toBe(true); }); it('.在负数数字类型字符串结尾', () => { expect(isEndWithDotNum('-123.')).toBe(true); }); it('.在数字类型字符串中间', () => { expect(isEndWithDotNum('12.3')).toBe(false); }); it('.在数字类型字符串开头', () => { expect(isEndWithDotNum('.123')).toBe(false); }); it('.在字符串结尾', () => { expect(isEndWithDotNum('123undefined.')).toBe(false); }); });