mirror of
https://github.com/status-im/consul.git
synced 2025-01-09 13:26:07 +00:00
6589cbbd0d
* ui: Add the most basic workspace root in /ui * We already have a LICENSE file in the repository root * Change directory path in build scripts ui-v2 -> ui * Make yarn install flags configurable from elsewhere * Minimal workspace root makefile * Call the new docker specific target * Update yarn in the docker build image * Reconfigure the netlify target and move to the higher makefile * Move ui-v2 -> ui/packages/consul-ui * Change repo root to refleect new folder structure * Temporarily don't hoist consul-api-double * Fixup CI configuration * Fixup lint errors * Fixup Netlify target
64 lines
1.7 KiB
JavaScript
64 lines
1.7 KiB
JavaScript
import domClickFirstAnchor from 'consul-ui/utils/dom/click-first-anchor';
|
|
import { module, test } from 'qunit';
|
|
|
|
module('Unit | Utility | dom/click first anchor', function() {
|
|
test('it does nothing if the clicked element is generally a clickable thing', function(assert) {
|
|
const closest = function() {
|
|
return {
|
|
querySelector: function() {
|
|
assert.ok(false);
|
|
},
|
|
};
|
|
};
|
|
const click = domClickFirstAnchor(closest);
|
|
['INPUT', 'LABEL', 'A', 'Button'].forEach(function(item) {
|
|
const expected = null;
|
|
const actual = click({
|
|
target: {
|
|
nodeName: item,
|
|
},
|
|
});
|
|
assert.equal(actual, expected);
|
|
});
|
|
});
|
|
test("it does nothing if an anchor isn't found", function(assert) {
|
|
const closest = function() {
|
|
return {
|
|
querySelector: function() {
|
|
return null;
|
|
},
|
|
};
|
|
};
|
|
const click = domClickFirstAnchor(closest);
|
|
const expected = null;
|
|
const actual = click({
|
|
target: {
|
|
nodeName: 'DIV',
|
|
},
|
|
});
|
|
assert.equal(actual, expected);
|
|
});
|
|
test('it dispatches the result of `mouseup`, `mousedown`, `click` if an anchor is found', function(assert) {
|
|
assert.expect(3);
|
|
const expected = ['mousedown', 'mouseup', 'click'];
|
|
const closest = function() {
|
|
return {
|
|
querySelector: function() {
|
|
return {
|
|
dispatchEvent: function(ev) {
|
|
const actual = ev.type;
|
|
assert.equal(actual, expected.shift());
|
|
},
|
|
};
|
|
},
|
|
};
|
|
};
|
|
const click = domClickFirstAnchor(closest);
|
|
click({
|
|
target: {
|
|
nodeName: 'DIV',
|
|
},
|
|
});
|
|
});
|
|
});
|