Skip to content

Commit e6ae486

Browse files
committed
fix: 修复时间戳位数描述错误及格式化
1 parent 432ee86 commit e6ae486

8 files changed

+15
-31
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ console.log('jsUtilsLc.removeArrRepeat',jsUtilsLc.removeArrRepeat([1,2,3,3,4,9,8
159159

160160
2、使用`npm run jest 方法名` 跑某个方法的单元测试,如`npm run deepClone`
161161

162-
162+
3、使用`npm run jest:coverage` 跑覆盖率测试
163163

164164
# 五、待完成
165165
~~1、支持方便地在浏览器控制台实时测试/调试各个函数的运行效果~~

docs/src/__tests__/dateAndTimestampConversion.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ describe('dateAndTimestampConversion 方法测试', () => {
44
test('传时间戳展示年月日', () => {
55
expect(dateAndTimestampConversion(1660120671762)).toBe('2022-08-10')
66
})
7-
test('传8位时间戳展示年月日', () => {
7+
test('传10位时间戳展示年月日', () => {
88
expect(dateAndTimestampConversion(1660120671)).toBe('2022-08-10')
99
})
1010
test('传时间戳展示年月日时分秒', () => {
@@ -29,11 +29,11 @@ describe('dateAndTimestampConversion 方法测试', () => {
2929
test('日期字符串长度应为10或19位数', () => {
3030
expect(() => dateAndTimestampConversion('2022/08/100')).toThrow('日期位数应为10位数或19位数')
3131
})
32-
test('时间戳位数应为11位数或8位数', () => {
33-
expect(() => dateAndTimestampConversion(16600608000000)).toThrow('时间戳位数应为11位数或8位数')
32+
test('时间戳位数应为10位数或13位数', () => {
33+
expect(() => dateAndTimestampConversion(16600608000000)).toThrow('时间戳位数应为10位数或13位数')
3434
})
35-
test('时间戳位数应为11位数或8位数', () => {
36-
expect(() => dateAndTimestampConversion(166006080)).toThrow('时间戳位数应为11位数或8位数')
35+
test('时间戳位数应为10位数或13位数', () => {
36+
expect(() => dateAndTimestampConversion(166006080)).toThrow('时间戳位数应为10位数或13位数')
3737
})
3838
test('参数应为数字或字符串类型', () => {
3939
expect(() => dateAndTimestampConversion(new Date())).toThrow('参数应为数字或字符串类型')

docs/src/global/arrayEqual.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,13 @@ function arrayEqual(arr1, arr2) {
3333
return false
3434
}
3535
}
36-
3736
}else{
38-
if( arr1Sort[i] !==arr2Sort[i]){
37+
if(arr1Sort[i] !==arr2Sort[i]){
3938
return false
4039
}
4140
}
42-
4341
}
44-
4542
return true
46-
47-
4843
}
4944

5045
export default arrayEqual

docs/src/global/dateAndTimestampConversion.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717
const isTimeTypeIsNum= timeType ==='[object Number]';
1818
if(isTimeTypeIsNum && String(time).length !==10 && String(time).length !==13){
19-
throw new Error("时间戳位数应为11位数或8位数")
19+
throw new Error("时间戳位数应为10位数或13位数")
2020
}
2121
if(!isTimeTypeIsNum && time.length !==10 && time.length !==19){
2222
throw new Error("日期位数应为10位数或19位数")

src/__tests__/arrayEqual.spec.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,4 @@ describe('arrayEqual 方法测试', () => {
110110
const arr2 = null;
111111
expect(() => arrayEqual(arr1, arr2)).toThrow('参数不为数组,无法比较');
112112
})
113-
114-
115-
116-
117-
118-
119113
})

src/__tests__/dateAndTimestampConversion.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ describe('dateAndTimestampConversion 方法测试', () => {
44
test('传时间戳展示年月日', () => {
55
expect(dateAndTimestampConversion(1660120671762)).toBe('2022-08-10')
66
})
7-
test('传8位时间戳展示年月日', () => {
7+
test('传10位时间戳展示年月日', () => {
88
expect(dateAndTimestampConversion(1660120671)).toBe('2022-08-10')
99
})
1010
test('传时间戳展示年月日时分秒', () => {
@@ -29,11 +29,11 @@ describe('dateAndTimestampConversion 方法测试', () => {
2929
test('日期字符串长度应为10或19位数', () => {
3030
expect(() => dateAndTimestampConversion('2022/08/100')).toThrow('日期位数应为10位数或19位数')
3131
})
32-
test('时间戳位数应为11位数或8位数', () => {
33-
expect(() => dateAndTimestampConversion(16600608000000)).toThrow('时间戳位数应为11位数或8位数')
32+
test('时间戳位数应为10位数或13位数', () => {
33+
expect(() => dateAndTimestampConversion(16600608000000)).toThrow('时间戳位数应为10位数或13位数')
3434
})
35-
test('时间戳位数应为11位数或8位数', () => {
36-
expect(() => dateAndTimestampConversion(166006080)).toThrow('时间戳位数应为11位数或8位数')
35+
test('时间戳位数应为10位数或13位数', () => {
36+
expect(() => dateAndTimestampConversion(166006080)).toThrow('时间戳位数应为10位数或13位数')
3737
})
3838
test('参数应为数字或字符串类型', () => {
3939
expect(() => dateAndTimestampConversion(new Date())).toThrow('参数应为数字或字符串类型')

src/global/arrayEqual.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,13 @@ function arrayEqual(arr1, arr2) {
3333
return false
3434
}
3535
}
36-
3736
}else{
38-
if( arr1Sort[i] !==arr2Sort[i]){
37+
if(arr1Sort[i] !==arr2Sort[i]){
3938
return false
4039
}
4140
}
42-
4341
}
44-
4542
return true
46-
47-
4843
}
4944

5045
export default arrayEqual

src/global/dateAndTimestampConversion.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
}
1717
const isTimeTypeIsNum= timeType ==='[object Number]';
1818
if(isTimeTypeIsNum && String(time).length !==10 && String(time).length !==13){
19-
throw new Error("时间戳位数应为11位数或8位数")
19+
throw new Error("时间戳位数应为10位数或13位数")
2020
}
2121
if(!isTimeTypeIsNum && time.length !==10 && time.length !==19){
2222
throw new Error("日期位数应为10位数或19位数")

0 commit comments

Comments
 (0)