Skip to content

Commit 25c2ff4

Browse files
committed
test: verify Auto dataBind still binds when default ViewModel exists
1 parent 192f8a5 commit 25c2ff4

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

example/__tests__/autoplay.harness.tsx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,45 @@ describe('autoPlay prop (issue #138)', () => {
270270
});
271271

272272
describe('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

0 commit comments

Comments
 (0)