Skip to content

Instantly share code, notes, and snippets.

@DimitryDushkin
Created July 20, 2019 20:24
Show Gist options
  • Save DimitryDushkin/d328ed41da51b3cda727ecd554e37f27 to your computer and use it in GitHub Desktop.
Save DimitryDushkin/d328ed41da51b3cda727ecd554e37f27 to your computer and use it in GitHub Desktop.
import { marbles } from "rxjs-marbles/jest";
import { createDragObservable } from "./use-draggable";
const data = {
d: new PointerEvent('mousedown'),
m: new PointerEvent('mousedown'),
u: new PointerEvent('mousedown'),
}
describe("useDraggable", () => {
it(
"emits drag events only after mousedown and end after mouseup",
marbles(m => {
const down$ = m.hot("-d--------", data);
const move$ = m.hot("mmmmm-mmmm", data);
const up$ = m.hot("-------u--", data);
const expectedDrag$ = m.hot("-eeee-ee--", {e: {x: 0, y: 0}});
const drag$ = createDragObservable(up$, down$, move$);
m.expect(drag$).toBeObservable(expectedDrag$);
})
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment