Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DomUtil function tests #7547

Merged
merged 11 commits into from
Apr 15, 2022
Prev Previous commit
Next Next commit
Added getSizeparentnode and getscale tests
  • Loading branch information
LGNorris committed Apr 8, 2021
commit a166f2646367cc3ddae915f5d2474e6f56d44867
80 changes: 63 additions & 17 deletions spec/suites/dom/DomUtilSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ describe('DomUtil', function () {
var el;

beforeEach(function () {
var el = document.createElement('div');
var input = document.createElement('input');
input.value = 'xxx';
el = document.createElement('div');
el.style.position = 'absolute';
el.style.top = el.style.left = '-10000px';
el.style.top = el.style.left = '0px';
document.body.appendChild(el);
document.body.appendChild(input);
});

afterEach(function () {
Expand Down Expand Up @@ -173,8 +170,8 @@ describe('DomUtil', function () {

describe('#setPosition, #getPosition', function () {
it("Sets position of el to coordinates specified by position.", function () {
Falke-Design marked this conversation as resolved.
Show resolved Hide resolved
expect(L.DomUtil.getStyle(el, 'left')).to.be.equal('-10000px');
expect(L.DomUtil.getStyle(el, 'top')).to.be.equal('-10000px');
expect(L.DomUtil.getStyle(el, 'left')).to.be.equal('0px');
expect(L.DomUtil.getStyle(el, 'top')).to.be.equal('0px');

var x = 100;
var y = 100;
Expand All @@ -201,18 +198,67 @@ describe('DomUtil', function () {
});
});

describe('#getSizedParentNode', function () {
Falke-Design marked this conversation as resolved.
Show resolved Hide resolved
it('Find nearest parent element where height / width are not null', function () {
var parentEl = document.createElement('div');
var childEl = document.createElement('div');
el.appendChild(parentEl);
parentEl.appendChild(childEl);
expect(L.DomUtil.getSizedParentNode(childEl)).to.not.eql(parentEl)
parentEl.style.width = '150px';
parentEl.style.height = '150px';
expect(L.DomUtil.getSizedParentNode(childEl)).to.eql(parentEl);
});
});

describe('#getScale', function () {
Falke-Design marked this conversation as resolved.
Show resolved Hide resolved
it('Returns scale of element as x & y scales respectively', function () {
var childEl = document.createElement('div');
el.appendChild(childEl);
var scale = {
x: 1,
y: 1,
boundingClientRect: {
left: 25,
right: 305,
top: 25,
height: 280,
bottom: 305,
width: 280
}
}
childEl.style.width = '250px';
childEl.style.height = '250px';
childEl.style.padding = '15px';
childEl.style.margin = '25px';
expect(L.DomUtil.getScale(childEl)).to.eql(scale)
childEl.style.padding = '400px';
expect(L.DomUtil.getScale(childEl)).to.not.eql(scale)
})
});


describe('#disableTextSelection', function () {
it('Disable the selectstart DOM events for the user ', function () {
// var listener = sinon.spy();
// console.log('selectstart' in window)
// L.DomUtil.disableTextSelection()
// console.log('onselectstart' in window)
// // L.DomEvent.on(window, 'selectstart', listener)
// // happen.once(window, {
// // type: "selectstart"
// // })
// // expect(listener.called).to.be.ok()
// L.DomUtil.disableTextSelection()

});
});

describe('#enableTextSelection', function () {
it('Enable the selectstart DOM events for the user ', function () {

});
});

describe('#preventOutline', function () {
it('Makes outline of passed element invisible', function () {

});
});

describe('#restoreOutline', function () {
it('Restores outline for element if not already visible', function () {

});
});

Expand Down