-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
xuying.xu
committed
Apr 10, 2024
1 parent
f307f6d
commit cbaf267
Showing
3 changed files
with
264 additions
and
38 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
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,196 @@ | ||
import { jsx, Canvas, Component, createRef } from '../../src'; | ||
import { createContext, delay } from '../util'; | ||
const context = createContext(); | ||
import { Renderer } from '@antv/g-mobile-canvas'; | ||
|
||
|
||
describe('polyline', () => { | ||
it('polyline', async () => { | ||
const renderer = new Renderer(); | ||
const context = createContext('polyline'); | ||
|
||
const { props } = ( | ||
<Canvas renderer={renderer} context={context}> | ||
<polyline | ||
style={{ | ||
points: [ | ||
[0, 10], | ||
[20, 80], | ||
[40, 40], | ||
[60, 10], | ||
[80, 60] | ||
], | ||
stroke: 'blue' | ||
}} | ||
animation={{ | ||
update: { | ||
easing: 'linear', | ||
duration: 100, | ||
property: ['points'], | ||
}, | ||
}} | ||
/> | ||
</Canvas> | ||
); | ||
const canvas = new Canvas(props); | ||
await canvas.render(); | ||
await delay(500); | ||
expect(context).toMatchImageSnapshot(); | ||
}) | ||
it('step start polyline', async () => { | ||
const renderer = new Renderer(); | ||
const context = createContext('step start polyline'); | ||
|
||
const { props } = ( | ||
<Canvas renderer={renderer} context={context}> | ||
<polyline | ||
style={{ | ||
points: [ | ||
[0, 10], | ||
[20, 80], | ||
[40, 40], | ||
[60, 10], | ||
[80, 60] | ||
], | ||
stroke: 'blue' | ||
}} | ||
animation={{ | ||
update: { | ||
easing: 'linear', | ||
duration: 100, | ||
property: ['points'], | ||
}, | ||
}} | ||
/> | ||
<polyline | ||
style={{ | ||
points: [ | ||
[0, 10], | ||
[20, 80], | ||
[40, 40], | ||
[60, 10], | ||
[80, 60] | ||
], | ||
stroke: 'red', | ||
stepStart: true, | ||
}} | ||
animation={{ | ||
update: { | ||
easing: 'linear', | ||
duration: 200, | ||
property: ['points'], | ||
}, | ||
}} | ||
/> | ||
</Canvas> | ||
); | ||
const canvas = new Canvas(props); | ||
await canvas.render(); | ||
await delay(500); | ||
expect(context).toMatchImageSnapshot(); | ||
}) | ||
it('step middle polyline', async () => { | ||
const renderer = new Renderer(); | ||
const context = createContext('step middle polyline'); | ||
|
||
const { props } = ( | ||
<Canvas renderer={renderer} context={context}> | ||
<polyline | ||
style={{ | ||
points: [ | ||
[0, 10], | ||
[20, 80], | ||
[40, 40], | ||
[60, 10], | ||
[80, 60] | ||
], | ||
stroke: 'blue' | ||
}} | ||
animation={{ | ||
update: { | ||
easing: 'linear', | ||
duration: 100, | ||
property: ['points'], | ||
}, | ||
}} | ||
/> | ||
<polyline | ||
style={{ | ||
points: [ | ||
[0, 10], | ||
[20, 80], | ||
[40, 40], | ||
[60, 10], | ||
[80, 60] | ||
], | ||
stroke: 'red', | ||
stepMiddle: true, | ||
}} | ||
animation={{ | ||
update: { | ||
easing: 'linear', | ||
duration: 200, | ||
property: ['points'], | ||
}, | ||
}} | ||
/> | ||
</Canvas> | ||
); | ||
const canvas = new Canvas(props); | ||
await canvas.render(); | ||
await delay(500); | ||
expect(context).toMatchImageSnapshot(); | ||
}) | ||
it('step end polyline', async () => { | ||
const renderer = new Renderer(); | ||
const context = createContext('step end polyline'); | ||
|
||
const { props } = ( | ||
<Canvas renderer={renderer} context={context}> | ||
<polyline | ||
style={{ | ||
points: [ | ||
[0, 10], | ||
[20, 80], | ||
[40, 40], | ||
[60, 10], | ||
[80, 60] | ||
], | ||
stroke: 'blue' | ||
}} | ||
animation={{ | ||
update: { | ||
easing: 'linear', | ||
duration: 100, | ||
property: ['points'], | ||
}, | ||
}} | ||
/> | ||
<polyline | ||
style={{ | ||
points: [ | ||
[0, 10], | ||
[20, 80], | ||
[40, 40], | ||
[60, 10], | ||
[80, 60] | ||
], | ||
stroke: 'red', | ||
stepEnd: true, | ||
}} | ||
animation={{ | ||
update: { | ||
easing: 'linear', | ||
duration: 200, | ||
property: ['points'], | ||
}, | ||
}} | ||
/> | ||
</Canvas> | ||
); | ||
const canvas = new Canvas(props); | ||
await canvas.render(); | ||
await delay(500); | ||
expect(context).toMatchImageSnapshot(); | ||
}) | ||
}); |