Skip to content

Commit

Permalink
added a test for the mouse bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
mjtalbot committed Jul 22, 2022
1 parent db3646b commit 0a42e36
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions js/test/rive.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,45 @@ test('Artboards can be reset back to their starting state', (done) => {

// #endregion

// #region remove mouse events

test('Mouse events are removed from canvas when reset', (done) => {
const canvas = document.createElement('canvas');
let resetMe = true;

// Start up a looping animation
const r = new rive.Rive({
canvas: canvas,
buffer: stateMachineFileBuffer,
autoplay: true,
artboard: 'MyArtboard',
stateMachines: 'StateMachine',
onStateChange: () => {
// lets make sure we're moving so we got things registered
if (resetMe) {
resetMe = false;
r.reset({
artboard: 'MyArtboard',
stateMachines: 'StateMachine',
autoplay: true,
});
}
if (!resetMe) {
try {
// This will fake a mouse event, and trigger their event handlers
// If those are illegal, we'll crash
canvas.dispatchEvent(new Event('mousedown'));
} catch (err) {
done(err);
}
done();
}
},
});
});

// #endregion

test('Statemachines have pointer events', (done) => {
rive.RuntimeLoader.awaitInstance().then(async (runtime) => {
const file = await runtime.load(new Uint8Array(stateMachineFileBuffer));
Expand Down

0 comments on commit 0a42e36

Please sign in to comment.