Skip to content

Commit

Permalink
Move stub to helper file
Browse files Browse the repository at this point in the history
Define containers once

Create new instance for each test

Linting

Linting

Add assertion, update stub

Use expecteds

Move expecteds up in scope

Use triggerEvent helper
  • Loading branch information
timrourke committed Jan 9, 2018
1 parent bbf726f commit 05c77b1
Show file tree
Hide file tree
Showing 2 changed files with 148 additions and 117 deletions.
37 changes: 37 additions & 0 deletions scripts/test/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,40 @@ export function triggerEvent(element, type, data = {}) {
element.dispatchEvent(event);
return event;
}

/**
* A stub of the Plugin class
*
* @class PluginStub
*/
export class PluginStub {

/**
* Constructor.
*
* @param {Draggable} draggable
*/
constructor(draggable) {
this.attachWasCalled = false;
this.detachWasCalled = false;
this.draggable = draggable;
this.numTimesAttachCalled = 0;
this.numTimesDetachCalled = 0;
}

/**
* Set a testable property when `attach` is called
*/
attach() {
this.attachWasCalled = true;
this.numTimesAttachCalled++;
}

/**
* Set a testable property when `detach` is called
*/
detach() {
this.detachWasCalled = true;
this.numTimesDetachCalled++;
}
}
Loading

0 comments on commit 05c77b1

Please sign in to comment.