UNPKG

2.32 kBTypeScriptView Raw
1import { DrakeWithModels } from './DrakeWithModels';
2import { EventTypes } from './EventTypes';
3import { DragulaOptions } from './DragulaOptions';
4import { DrakeFactory } from './DrakeFactory';
5export declare const MockDrakeFactory: DrakeFactory;
6/** You can use MockDrake to simulate Drake events.
7 *
8 * The three methods that actually do anything are `on(event, listener)`,
9 * `destroy()`, and a new method, `emit()`. Use `emit()` to manually emit Drake
10 * events, and if you injected MockDrake properly with MockDrakeFactory or
11 * mocked the DragulaService.find() method, then you can make ng2-dragula think
12 * drags and drops are happening.
13 *
14 * Caveats:
15 *
16 * 1. YOU MUST MAKE THE DOM CHANGES YOURSELF.
17 * 2. REPEAT: YOU MUST MAKE THE DOM CHANGES YOURSELF.
18 * That means `source.removeChild(el)`, and `target.insertBefore(el)`.
19 * 3. None of the other methods do anything.
20 * That's ok, because ng2-dragula doesn't use them.
21 */
22export declare class MockDrake implements DrakeWithModels {
23 containers: Element[];
24 options: DragulaOptions;
25 models: any[][];
26 /**
27 * @param containers A list of container elements.
28 * @param options These will NOT be used. At all.
29 * @param models Nonstandard, but useful for testing using `new MockDrake()` directly.
30 * Note, default value is undefined, like a real Drake. Don't change that.
31 */
32 constructor(containers?: Element[], options?: DragulaOptions, models?: any[][]);
33 dragging: boolean;
34 start(item: Element): any;
35 end(): any;
36 cancel(revert: boolean): any;
37 cancel(): any;
38 remove(): any;
39 private emitter$;
40 private subs;
41 on(event: string, callback: Function): any;
42 destroy(): any;
43 /**
44 * This is the most useful method. You can use it to manually fire events that would normally
45 * be fired by a real drake.
46 *
47 * You're likely most interested in firing `drag`, `remove` and `drop`, the three events
48 * DragulaService uses to implement [dragulaModel].
49 *
50 * See https://github.com/bevacqua/dragula#drakeon-events for what you should emit (and in what order).
51 *
52 * (Note also, firing dropModel and removeModel won't work. You would have to mock DragulaService for that.)
53 */
54 emit(eventType: EventTypes, ...args: any[]): void;
55}