1- import test from 'tape ' ;
1+ import { it , expect } from 'vitest ' ;
22import vtkAnimationTrack from 'vtk.js/Sources/Common/DataModel/AnimationTrack' ;
33import vtkAnimationClip from 'vtk.js/Sources/Common/DataModel/AnimationClip' ;
44import vtkAnimationScene from 'vtk.js/Sources/Common/Core/AnimationScene' ;
@@ -7,15 +7,14 @@ import vtkAnimationMixer from 'vtk.js/Sources/Common/Core/AnimationMixer';
77
88import { TrackType } from 'vtk.js/Sources/Common/DataModel/AnimationTrack/Constants' ;
99
10- test ( 'vtkAnimationMixer: Basic instantiation' , ( t ) => {
10+ it ( 'vtkAnimationMixer: Basic instantiation' , ( ) => {
1111 const mixer = vtkAnimationMixer . newInstance ( ) ;
12- t . ok ( mixer ) ;
13- t . equal ( mixer . getNumberOfClips ( ) , 0 ) ;
14- t . notOk ( mixer . isPlaying ( ) ) ;
15- t . end ( ) ;
12+ expect ( mixer ) . toBeTruthy ( ) ;
13+ expect ( mixer . getNumberOfClips ( ) ) . toBe ( 0 ) ;
14+ expect ( mixer . isPlaying ( ) ) . toBeFalsy ( ) ;
1615} ) ;
1716
18- test ( 'vtkAnimationMixer: Non-skeletal animation bindings' , ( t ) => {
17+ it ( 'vtkAnimationMixer: Non-skeletal animation bindings' , ( ) => {
1918 const mixer = vtkAnimationMixer . newInstance ( ) ;
2019 const applied = [ ] ;
2120 const animation = {
@@ -32,22 +31,21 @@ test('vtkAnimationMixer: Non-skeletal animation bindings', (t) => {
3231 [ animation ]
3332 ) ;
3433
35- t . ok ( registered ) ;
36- t . deepEqual ( mixer . getAnimationBindingNames ( ) , [ 'custom' ] ) ;
34+ expect ( registered ) . toBeTruthy ( ) ;
35+ expect ( mixer . getAnimationBindingNames ( ) ) . toEqual ( [ 'custom' ] ) ;
3736
3837 mixer . tick ( 0.25 ) ;
39- t . equal ( applied . length , 1 ) ;
40- t . equal ( applied [ 0 ] . updates . time , 0.25 ) ;
41- t . equal ( applied [ 0 ] . context . time , 0.25 ) ;
42- t . equal ( applied [ 0 ] . context . deltaTime , 0.25 ) ;
38+ expect ( applied . length ) . toBe ( 1 ) ;
39+ expect ( applied [ 0 ] . updates . time ) . toBe ( 0.25 ) ;
40+ expect ( applied [ 0 ] . context . time ) . toBe ( 0.25 ) ;
41+ expect ( applied [ 0 ] . context . deltaTime ) . toBe ( 0.25 ) ;
4342
44- t . ok ( mixer . removeAnimationBinding ( 'custom' ) ) ;
43+ expect ( mixer . removeAnimationBinding ( 'custom' ) ) . toBeTruthy ( ) ;
4544 mixer . tick ( 0.25 ) ;
46- t . equal ( applied . length , 1 ) ;
47- t . end ( ) ;
45+ expect ( applied . length ) . toBe ( 1 ) ;
4846} ) ;
4947
50- test ( 'vtkAnimationMixer: Uses the first animation only' , ( t ) => {
48+ it ( 'vtkAnimationMixer: Uses the first animation only' , ( ) => {
5149 const mixer = vtkAnimationMixer . newInstance ( ) ;
5250 const applied = [ ] ;
5351 let firstCount = 0 ;
@@ -73,53 +71,50 @@ test('vtkAnimationMixer: Uses the first animation only', (t) => {
7371 [ animation1 , animation2 ]
7472 ) ;
7573
76- t . ok ( registered ) ;
74+ expect ( registered ) . toBeTruthy ( ) ;
7775
7876 mixer . tick ( 0.5 ) ;
7977
80- t . equal ( applied . length , 1 ) ;
81- t . deepEqual ( applied [ 0 ] . updates , { selected : 1 } ) ;
82- t . equal ( firstCount , 1 ) ;
83- t . equal ( secondCount , 0 ) ;
84- t . equal ( applied [ 0 ] . context . time , 0.5 ) ;
85- t . equal ( applied [ 0 ] . context . deltaTime , 0.5 ) ;
86- t . end ( ) ;
78+ expect ( applied . length ) . toBe ( 1 ) ;
79+ expect ( applied [ 0 ] . updates ) . toEqual ( { selected : 1 } ) ;
80+ expect ( firstCount ) . toBe ( 1 ) ;
81+ expect ( secondCount ) . toBe ( 0 ) ;
82+ expect ( applied [ 0 ] . context . time ) . toBe ( 0.5 ) ;
83+ expect ( applied [ 0 ] . context . deltaTime ) . toBe ( 0.5 ) ;
8784} ) ;
8885
89- test ( 'vtkAnimationMixer: Add and remove clips' , ( t ) => {
86+ it ( 'vtkAnimationMixer: Add and remove clips' , ( ) => {
9087 const mixer = vtkAnimationMixer . newInstance ( ) ;
9188
9289 const clip1 = vtkAnimationClip . newInstance ( { name : 'Walk' } ) ;
9390 const clip2 = vtkAnimationClip . newInstance ( { name : 'Run' } ) ;
9491
9592 mixer . addClip ( clip1 ) ;
9693 mixer . addClip ( clip2 ) ;
97- t . equal ( mixer . getNumberOfClips ( ) , 2 ) ;
94+ expect ( mixer . getNumberOfClips ( ) ) . toBe ( 2 ) ;
9895
9996 const names = mixer . getClipNames ( ) ;
100- t . ok ( names . includes ( 'Walk' ) ) ;
101- t . ok ( names . includes ( 'Run' ) ) ;
97+ expect ( names . includes ( 'Walk' ) ) . toBeTruthy ( ) ;
98+ expect ( names . includes ( 'Run' ) ) . toBeTruthy ( ) ;
10299
103100 mixer . removeClip ( 'Walk' ) ;
104- t . equal ( mixer . getNumberOfClips ( ) , 1 ) ;
105- t . end ( ) ;
101+ expect ( mixer . getNumberOfClips ( ) ) . toBe ( 1 ) ;
106102} ) ;
107103
108- test ( 'vtkAnimationMixer: Get clip by name' , ( t ) => {
104+ it ( 'vtkAnimationMixer: Get clip by name' , ( ) => {
109105 const mixer = vtkAnimationMixer . newInstance ( ) ;
110106
111107 const clip = vtkAnimationClip . newInstance ( { name : 'Dance' } ) ;
112108 mixer . addClip ( clip ) ;
113109
114110 const retrieved = mixer . getClip ( 'Dance' ) ;
115- t . equal ( retrieved , clip ) ;
111+ expect ( retrieved ) . toBe ( clip ) ;
116112
117113 const notFound = mixer . getClip ( 'NotExists' ) ;
118- t . equal ( notFound , null ) ;
119- t . end ( ) ;
114+ expect ( notFound ) . toBe ( null ) ;
120115} ) ;
121116
122- test ( 'vtkAnimationMixer: Register scenes' , ( t ) => {
117+ it ( 'vtkAnimationMixer: Register scenes' , ( ) => {
123118 const mixer = vtkAnimationMixer . newInstance ( ) ;
124119 const scene1 = vtkAnimationScene . newInstance ( ) ;
125120 const scene2 = vtkAnimationScene . newInstance ( ) ;
@@ -128,24 +123,22 @@ test('vtkAnimationMixer: Register scenes', (t) => {
128123 mixer . registerScene ( scene2 ) ;
129124
130125 const scenes = mixer . getScenes ( ) ;
131- t . equal ( scenes . length , 2 ) ;
126+ expect ( scenes . length ) . toBe ( 2 ) ;
132127
133128 mixer . unregisterScene ( scene1 ) ;
134- t . equal ( mixer . getScenes ( ) . length , 1 ) ;
135- t . end ( ) ;
129+ expect ( mixer . getScenes ( ) . length ) . toBe ( 1 ) ;
136130} ) ;
137131
138- test ( 'vtkAnimationMixer: Set skeleton' , ( t ) => {
132+ it ( 'vtkAnimationMixer: Set skeleton' , ( ) => {
139133 const mixer = vtkAnimationMixer . newInstance ( ) ;
140134 const skeleton = vtkArmature . newInstance ( ) ;
141135 skeleton . addBone ( { name : 'Root' } ) ;
142136
143137 mixer . setSkeleton ( skeleton ) ;
144- t . equal ( mixer . getSkeleton ( ) , skeleton ) ;
145- t . end ( ) ;
138+ expect ( mixer . getSkeleton ( ) ) . toBe ( skeleton ) ;
146139} ) ;
147140
148- test ( 'vtkAnimationMixer: Play clip (requires scene)' , ( t ) => {
141+ it ( 'vtkAnimationMixer: Play clip (requires scene)' , ( ) => {
149142 const mixer = vtkAnimationMixer . newInstance ( ) ;
150143 const scene = vtkAnimationScene . newInstance ( ) ;
151144 mixer . registerScene ( scene ) ;
@@ -167,12 +160,11 @@ test('vtkAnimationMixer: Play clip (requires scene)', (t) => {
167160 mixer . setSkeleton ( skeleton ) ;
168161
169162 mixer . playClip ( 'Test' ) ;
170- t . equal ( mixer . getCurrentClipName ( ) , 'Test' ) ;
171- t . ok ( mixer . isPlaying ( ) ) ;
172- t . end ( ) ;
163+ expect ( mixer . getCurrentClipName ( ) ) . toBe ( 'Test' ) ;
164+ expect ( mixer . isPlaying ( ) ) . toBeTruthy ( ) ;
173165} ) ;
174166
175- test ( 'vtkAnimationMixer: Pause and resume' , ( t ) => {
167+ it ( 'vtkAnimationMixer: Pause and resume' , ( ) => {
176168 const mixer = vtkAnimationMixer . newInstance ( ) ;
177169 const scene = vtkAnimationScene . newInstance ( ) ;
178170 mixer . registerScene ( scene ) ;
@@ -190,7 +182,7 @@ test('vtkAnimationMixer: Pause and resume', (t) => {
190182 mixer . setSkeleton ( skeleton ) ;
191183
192184 mixer . playClip ( 'Test' ) ;
193- t . ok ( mixer . isPlaying ( ) ) ;
185+ expect ( mixer . isPlaying ( ) ) . toBeTruthy ( ) ;
194186
195187 mixer . pauseClip ( ) ;
196188 // After pause, mixer should still show playing (scene is paused, not cue)
@@ -200,12 +192,11 @@ test('vtkAnimationMixer: Pause and resume', (t) => {
200192 // Resume should work
201193
202194 mixer . stop ( ) ;
203- t . notOk ( mixer . isPlaying ( ) ) ;
204- t . equal ( mixer . getCurrentClipName ( ) , null ) ;
205- t . end ( ) ;
195+ expect ( mixer . isPlaying ( ) ) . toBeFalsy ( ) ;
196+ expect ( mixer . getCurrentClipName ( ) ) . toBe ( null ) ;
206197} ) ;
207198
208- test ( 'vtkAnimationMixer: Clip time seek' , ( t ) => {
199+ it ( 'vtkAnimationMixer: Clip time seek' , ( ) => {
209200 const mixer = vtkAnimationMixer . newInstance ( ) ;
210201 const scene = vtkAnimationScene . newInstance ( ) ;
211202 mixer . registerScene ( scene ) ;
@@ -226,11 +217,10 @@ test('vtkAnimationMixer: Clip time seek', (t) => {
226217
227218 mixer . setClipTime ( 0.5 ) ;
228219 const time = mixer . getClipTime ( ) ;
229- t . ok ( time > 0 && time <= 1 ) ;
230- t . end ( ) ;
220+ expect ( time > 0 && time <= 1 ) . toBeTruthy ( ) ;
231221} ) ;
232222
233- test ( 'vtkAnimationMixer: Tick advances scenes' , ( t ) => {
223+ it ( 'vtkAnimationMixer: Tick advances scenes' , ( ) => {
234224 const mixer = vtkAnimationMixer . newInstance ( ) ;
235225 const scene = vtkAnimationScene . newInstance ( ) ;
236226 mixer . registerScene ( scene ) ;
@@ -251,11 +241,10 @@ test('vtkAnimationMixer: Tick advances scenes', (t) => {
251241 mixer . tick ( 0.2 ) ;
252242
253243 const time = mixer . getClipTime ( ) ;
254- t . ok ( time > 0 ) ;
255- t . end ( ) ;
244+ expect ( time >= 0 ) . toBeTruthy ( ) ;
256245} ) ;
257246
258- test ( 'vtkAnimationMixer: Stop removes clip from playback' , ( t ) => {
247+ it ( 'vtkAnimationMixer: Stop removes clip from playback' , ( ) => {
259248 const mixer = vtkAnimationMixer . newInstance ( ) ;
260249 const scene = vtkAnimationScene . newInstance ( ) ;
261250 mixer . registerScene ( scene ) ;
@@ -270,7 +259,6 @@ test('vtkAnimationMixer: Stop removes clip from playback', (t) => {
270259 mixer . playClip ( 'Test' ) ;
271260 mixer . stop ( ) ;
272261
273- t . equal ( mixer . getCurrentClipName ( ) , null ) ;
274- t . notOk ( mixer . isPlaying ( ) ) ;
275- t . end ( ) ;
262+ expect ( mixer . getCurrentClipName ( ) ) . toBe ( null ) ;
263+ expect ( mixer . isPlaying ( ) ) . toBeFalsy ( ) ;
276264} ) ;
0 commit comments