feat:添加自动化测试
This commit is contained in:
17
nezha-fronted/test/unit/specs/example.spec.js
Normal file
17
nezha-fronted/test/unit/specs/example.spec.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import { dealLegendAlias } from '@/components/common/js/tools'
|
||||
describe('别名替换函数', () => {
|
||||
// 测试代码可读性最好
|
||||
// 分组
|
||||
it('正常替换一个', () => {
|
||||
expect(dealLegendAlias('{a:1,b:2}', '{{a}}')).toBe('1')
|
||||
})
|
||||
it('正常替换多个个', () => {
|
||||
expect(dealLegendAlias('{a:1,b:2}', '{{a}}{{b}}')).toBe('12')
|
||||
})
|
||||
it('匹配不到', () => {
|
||||
expect(dealLegendAlias('{a:1,b:2}', '{{c}}')).toBe('')
|
||||
})
|
||||
it('没有legend', () => {
|
||||
expect(dealLegendAlias('{a:1,b:2}', '')).toBe('{a:1,b:2}')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user