CN-1391 fix: 修复一系列bug
This commit is contained in:
@@ -13,3 +13,65 @@ export const undefinedData = {
|
||||
httpResponseLatency: undefined,
|
||||
establishLatencyMs: undefined
|
||||
}
|
||||
|
||||
export const commonData = {
|
||||
tcpLostlenPercent: 0.02,
|
||||
pktRetransPercent: 0.005,
|
||||
sslConLatency: 350,
|
||||
httpResponseLatency: 160,
|
||||
establishLatencyMs: 180
|
||||
}
|
||||
|
||||
export const commonScoreBase = {
|
||||
establishLatencyMs: {
|
||||
p10: 10,
|
||||
p90: 200
|
||||
},
|
||||
httpResponseLatency: {
|
||||
p10: 20,
|
||||
p90: 200
|
||||
},
|
||||
sslConLatency: {
|
||||
p10: 30,
|
||||
p90: 300
|
||||
},
|
||||
tcpLostlenPercent: {
|
||||
p10: 0.005,
|
||||
p90: 0.05
|
||||
},
|
||||
pktRetransPercent: {
|
||||
p10: 0.01,
|
||||
p90: 0.2
|
||||
}
|
||||
}
|
||||
|
||||
export const commonData2 = {
|
||||
tcpLostlenPercent: 0.034,
|
||||
pktRetransPercent: 0.145,
|
||||
sslConLatency: 500,
|
||||
httpResponseLatency: 32,
|
||||
establishLatencyMs: 183
|
||||
}
|
||||
|
||||
export const commonScoreBase2 = {
|
||||
establishLatencyMs: {
|
||||
p10: 90,
|
||||
p90: 250
|
||||
},
|
||||
httpResponseLatency: {
|
||||
p10: 60,
|
||||
p90: 200
|
||||
},
|
||||
sslConLatency: {
|
||||
p10: 300,
|
||||
p90: 800
|
||||
},
|
||||
tcpLostlenPercent: {
|
||||
p10: 0.01,
|
||||
p90: 0.2
|
||||
},
|
||||
pktRetransPercent: {
|
||||
p10: 0.05,
|
||||
p90: 0.3
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
import { computeScore } from '@/utils/tools'
|
||||
import { zeroData, undefinedData } from './mockData/score'
|
||||
import { zeroData, undefinedData, commonScoreBase, commonData, commonData2, commonScoreBase2 } from './mockData/score'
|
||||
|
||||
describe('computeScore测试', () => {
|
||||
test('含0', () => {
|
||||
expect(computeScore(zeroData)).toEqual(6)
|
||||
expect(computeScore(zeroData, commonScoreBase)).toEqual(6)
|
||||
})
|
||||
test('含undefined', () => {
|
||||
expect(computeScore(undefinedData)).toEqual('-')
|
||||
expect(computeScore(undefinedData, commonScoreBase)).toEqual('-')
|
||||
})
|
||||
test('普通数据', () => {
|
||||
expect(computeScore(commonData, commonScoreBase)).toEqual(4)
|
||||
})
|
||||
test('普通数据2', () => {
|
||||
expect(computeScore(commonData2, commonScoreBase2)).toEqual(4)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user