fix: 修复score有时计算不准确的问题
This commit is contained in:
15
test/utils/mockData/score.js
Normal file
15
test/utils/mockData/score.js
Normal file
@@ -0,0 +1,15 @@
|
||||
export const zeroData = {
|
||||
tcpLostlenPercent: 0,
|
||||
pktRetransPercent: 0,
|
||||
sslConLatency: null,
|
||||
httpResponseLatency: 0,
|
||||
establishLatencyMs: 0
|
||||
}
|
||||
|
||||
export const undefinedData = {
|
||||
tcpLostlenPercent: undefined,
|
||||
pktRetransPercent: undefined,
|
||||
sslConLatency: undefined,
|
||||
httpResponseLatency: undefined,
|
||||
establishLatencyMs: undefined
|
||||
}
|
||||
11
test/utils/tools.test.js
Normal file
11
test/utils/tools.test.js
Normal file
@@ -0,0 +1,11 @@
|
||||
import { computeScore } from '@/utils/tools'
|
||||
import { zeroData, undefinedData } from './mockData/score'
|
||||
|
||||
describe('computeScore测试', () => {
|
||||
test('含0', () => {
|
||||
expect(computeScore(zeroData)).toEqual(6)
|
||||
})
|
||||
test('含undefined', () => {
|
||||
expect(computeScore(undefinedData)).toEqual('-')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user