Skip to content

Commit

Permalink
chore: adds test coverage and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
schne324 committed Mar 27, 2018
1 parent fe57283 commit 0ada61d
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
node_modules/
dist/
.nyc_output/
coverage/
demo/
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
node_modules/
coverage/
.nyc_output/
11 changes: 10 additions & 1 deletion dist/dragon-drop.js
Original file line number Diff line number Diff line change
Expand Up @@ -2141,6 +2141,15 @@ LiveRegion.prototype.announce = function (msg, expire) {
}
};

/**
* destroy
* Removes the live region DOM node inserted on initialization
*/

LiveRegion.prototype.destroy = function () {
this.region.parentNode.removeChild(this.region)
};

/**
* Expose LiveRegion
*/
Expand Down Expand Up @@ -2656,4 +2665,4 @@ if (si) {

module.exports = tick;
},{}]},{},[1])(1)
});
});
4 changes: 2 additions & 2 deletions dist/dragon-drop.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
"deploy": "gh-pages -d dist/",
"dev": "watch-run -p 'lib/**,demo/**,index.js' npm run build",
"pre-build": "npm run clean && mkdir dist",
"test": "tape -r babel-register test/index.js | tap-spec && npm run lint",
"test": "npm run test:coverage && npm run lint",
"test:coverage": "nyc --reporter=text npm run test:run",
"test:run": "tape -r babel-register test/index.js | tap-spec",
"lint": "eslint ."
},
"repository": {
Expand Down
20 changes: 17 additions & 3 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'jsdom-global/register';
import test from 'tape';
import simulant, { fire } from 'simulant';
import DragonDrop from '../';
import DragonDrop from '../index';
import defaults from '../lib/defaults';
import queryAll from '../lib/query-all';
import Fixture from './helpers/fixture';
Expand Down Expand Up @@ -29,7 +29,7 @@ new DragonDrop(nested, {
nested: true,
item: '.top-level'
});
const ddSublist = new DragonDrop(sublist, {
const ddSublist = new DragonDrop([sublist], {
nested: true
});

Expand Down Expand Up @@ -162,6 +162,20 @@ test('clicks dragger when SPACE is pressed', t => {
fire(item, e);
});

test('clicks a pressed item when TAB is pressed', t => {
t.plan(1);
const item = ddWithoutDragger.items[1];
item.click(); // press it
const onItemClick = () => {
item.removeEventListener('click', onItemClick);
item.click(); // unpress it
t.pass();
};
item.addEventListener('click', onItemClick);
const e = simulant('keydown', { which: 9 });
fire(item, e);
});

test('properly moves item up when LEFT or UP is pressed and dragger is pressed', t => {
t.plan(2);

Expand Down Expand Up @@ -249,7 +263,7 @@ test('prevents click and keydown events from bubbling up given `nested: true`',
t.plan(1);

let called = false;
ddSublist.onKeydown({
ddSublist[0].onKeydown({
which: 32,
stopPropagation: () => called = true,
preventDefault: () => {},
Expand Down

0 comments on commit 0ada61d

Please sign in to comment.