File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -270,6 +270,45 @@ describe('autoPlay prop (issue #138)', () => {
270270} ) ;
271271
272272describe ( 'Auto dataBind with no default ViewModel (issue #189)' , ( ) => {
273+ it ( 'auto-binds default ViewModel when one exists' , async ( ) => {
274+ const file = await RiveFileFactory . fromSource ( BOUNCING_BALL , undefined ) ;
275+
276+ const context : TestContext = { ref : null , error : null } ;
277+ await render (
278+ < View style = { { width : 200 , height : 200 } } >
279+ < RiveView
280+ hybridRef = { {
281+ f : ( ref : RiveViewRef | null ) => {
282+ context . ref = ref ;
283+ } ,
284+ } }
285+ style = { { flex : 1 } }
286+ file = { file }
287+ autoPlay = { true }
288+ fit = { Fit . Contain }
289+ onError = { ( e ) => {
290+ context . error = e . message ;
291+ } }
292+ />
293+ </ View >
294+ ) ;
295+
296+ await waitFor (
297+ ( ) => {
298+ expect ( context . ref ) . not . toBeNull ( ) ;
299+ } ,
300+ { timeout : 5000 }
301+ ) ;
302+
303+ expect ( context . error ) . toBeNull ( ) ;
304+
305+ const vmi = context . ref ! . getViewModelInstance ( ) ;
306+ expect ( vmi ) . not . toBeNull ( ) ;
307+ expect ( vmi ! . numberProperty ( 'ypos' ) ) . toBeDefined ( ) ;
308+
309+ cleanup ( ) ;
310+ } ) ;
311+
273312 it ( 'plays without error when file has ViewModels but no artboard default' , async ( ) => {
274313 const file = await RiveFileFactory . fromSource ( NO_DEFAULT_VM , undefined ) ;
275314
You can’t perform that action at this time.
0 commit comments