-
Notifications
You must be signed in to change notification settings - Fork 605
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(pattern): 修复dot的stagger呈现问题,初步添加util中getCanvasPattern的单测 (#2786)
* feat(square-pattern): 添加square样式贴图 * fix: 修复square形状stroke的rotate问题 * refactor(pattern): 对代码进行一点整理,含类型定义 * refactor(types): 重新定义下 pattern 的属性定义 * chore: 升级官网 * refactor(pattern): 内置 pattern 的属性设计 & 优化下创建逻辑 (#2785) * feat(dot-pattern): 优化 dot pattern, 修复 stagger 展示 * feat(square-pattern): 优化 square pattern, 修复 stagger 展示 * refactor(pattern): 优化 line pattern & 删除无用代码 * refactor: 一些代码上的优化 & 删除无用的代码 * refactor(pattern): 初始化 canvas 的逻辑,抽取为一个 util 函数 * test: 修复dot的stagger呈现问题,初步添加util中getCanvasPattern的单测 * 修复: [BUG] 双轴图图例legend使用symbol的时候,颜色不能自动调整 (#2776) * fix: 修复 [BUG] 双轴图图例legend使用symbol的时候,颜色不能自动调整 * fix: 修复 [BUG] 双轴图图例legend使用symbol的时候,颜色不能自动调整 -2 Co-authored-by: ai-qing-hai <wb-xcf804241@antgroup.com> * test: 修复dot的stagger呈现问题,初步添加util中getCanvasPattern的单测 * refactor: 修改pattern单测中的写法 Co-authored-by: 酥云 <lisuwen.lsw@antgroup.com> Co-authored-by: visiky <736929286@qq.com> Co-authored-by: ai-qing-hai <65594180+ai-qing-hai@users.noreply.github.com> Co-authored-by: ai-qing-hai <wb-xcf804241@antgroup.com>
- Loading branch information
1 parent
ebb9e58
commit 7397bad
Showing
8 changed files
with
158 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { getCanvasPattern, PatternOption } from '../../../../src/utils/pattern'; | ||
|
||
describe('getCanvasPattern', () => { | ||
it('dot-pattern without cfg', () => { | ||
const pattern = getCanvasPattern({ type: 'dot' }); | ||
expect(pattern.toString()).toEqual('[object CanvasPattern]'); | ||
}); | ||
|
||
it('dot-pattern with cfg', () => { | ||
const patternOption = { | ||
type: 'dot', | ||
cfg: { | ||
radius: 4, | ||
padding: 6, | ||
}, | ||
} as PatternOption; | ||
const pattern = getCanvasPattern(patternOption); | ||
expect(pattern.toString()).toEqual('[object CanvasPattern]'); | ||
}); | ||
|
||
it('line-pattern without cfg', () => { | ||
const pattern = getCanvasPattern({ type: 'line' }); | ||
expect(pattern.toString()).toEqual('[object CanvasPattern]'); | ||
}); | ||
|
||
it('line-pattern with cfg', () => { | ||
const patternOption = { | ||
type: 'dot', | ||
cfg: { | ||
rotation: 0, | ||
spacing: 12, | ||
stroke: '#FFF', | ||
}, | ||
} as PatternOption; | ||
const pattern = getCanvasPattern(patternOption); | ||
expect(pattern.toString()).toEqual('[object CanvasPattern]'); | ||
}); | ||
|
||
it('square-pattern without cfg', () => { | ||
const pattern = getCanvasPattern({ type: 'square' }); | ||
expect(pattern.toString()).toEqual('[object CanvasPattern]'); | ||
}); | ||
|
||
it('square-pattern with cfg', () => { | ||
const patternOption = { | ||
type: 'dot', | ||
cfg: { | ||
size: 4, | ||
padding: 10, | ||
backgroundColor: 'transparent', | ||
fill: 'transparent', | ||
}, | ||
} as PatternOption; | ||
const pattern = getCanvasPattern(patternOption); | ||
expect(pattern.toString()).toEqual('[object CanvasPattern]'); | ||
}); | ||
|
||
it('pattern without option', () => { | ||
//@ts-ignore | ||
const pattern = getCanvasPattern({}); | ||
expect(pattern).toEqual(undefined); | ||
}); | ||
|
||
it('pattern with error type', () => { | ||
//@ts-ignore | ||
const pattern = getCanvasPattern({ type: 'xxx' }); | ||
expect(pattern).toEqual(undefined); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters