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
Test for testProp, setTransform and setPosition utils
  • Loading branch information
LGNorris committed Apr 3, 2021
commit cba5d83aea888017580b38d707f0a5992a0ca6c6
34 changes: 33 additions & 1 deletion spec/suites/dom/DomUtilSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe('DomUtil', function () {
expect(el.children.length).to.equal(0);
});
});

describe('#toFront, #toBack', function () {
Falke-Design marked this conversation as resolved.
Show resolved Hide resolved
beforeEach(function () {
L.DomUtil.create('div', 'childContainer', el);
Expand Down Expand Up @@ -142,6 +142,38 @@ describe('DomUtil', function () {
expect(el.style.opacity).to.equal('0');
});
});

describe('#testProp', function () {
Falke-Design marked this conversation as resolved.
Show resolved Hide resolved
it('Check array of style names return first valid style name for element', function () {
expect(L.DomUtil.testProp(['transform'])).to.not.be.ok();
document.documentElement.style.transform = 'rotate(0deg)';
expect(L.DomUtil.testProp(['transform'])).to.be.ok();
});
});

describe('#setTransform', function () {
Falke-Design marked this conversation as resolved.
Show resolved Hide resolved
it("Resets the transform style of an el.", function () {
expect(L.DomUtil.getStyle(el, '-webkit-transform')).to.be.equal('none');
Falke-Design marked this conversation as resolved.
Show resolved Hide resolved

var offset = L.point(200, 200);
var scale = 10;
L.DomUtil.setTransform(el, offset, scale);
var transform = L.DomUtil.getStyle(el, '-webkit-transform');
expect(L.DomUtil.getStyle(el, '-webkit-transform')).to.be.equal(transform);

var newScale = 20;
var newOffset = L.point(400, 400);
L.DomUtil.setTransform(el, newOffset, newScale);
expect(L.DomUtil.getStyle(el, '-webkit-transform')).to.not.be.equal(transform);
});
});

describe('#setPosition', function () {
it("Sets position of el to coordinates specified by position.", function () {
Falke-Design marked this conversation as resolved.
Show resolved Hide resolved
var position = L.point(100, 100);
L.DomUtil.setPosition(el, position);
});
});

// describe('#setPosition', noSpecs);

Expand Down