(nobug) - Fix tests for backport 1548784 (#5173)

This commit is contained in:
Andrei Oprea 2019-07-11 21:01:06 +02:00 коммит произвёл Ed Lee
Родитель fc04b9eae8
Коммит 06e41522a8
1 изменённых файлов: 26 добавлений и 5 удалений

Просмотреть файл

@ -20,7 +20,10 @@ describe("BookmarkPanelHub", () => {
sandbox = sinon.createSandbox();
globals = new GlobalOverrider();
fakeL10n = { setAttributes: sandbox.stub() };
fakeL10n = {
setAttributes: sandbox.stub(),
translateElements: sandbox.stub().resolves(),
};
globals.set("DOMLocalization", function() {
return fakeL10n;
}); // eslint-disable-line prefer-arrow-callback
@ -48,6 +51,12 @@ describe("BookmarkPanelHub", () => {
querySelector: sandbox.stub(),
children: [],
style: {},
getBoundingClientRect: sandbox.stub(),
};
const document = {
createElementNS: sandbox.stub().returns(fakeContainer),
getElementById: sandbox.stub().returns(fakeContainer),
l10n: fakeL10n,
};
fakeWindow = {
ownerGlobal: {
@ -55,10 +64,8 @@ describe("BookmarkPanelHub", () => {
gBrowser: { selectedBrowser: "browser" },
},
MozXULElement: { insertFTLIfNeeded: sandbox.stub() },
};
const document = {
createElementNS: sandbox.stub().returns(fakeContainer),
getElementById: sandbox.stub().returns(fakeContainer),
document,
requestAnimationFrame: x => x(),
};
fakeTarget = {
document,
@ -249,6 +256,19 @@ describe("BookmarkPanelHub", () => {
assert.equal(fakeL10n.setAttributes.callCount, 4);
});
it("call adjust panel height when height is > 150px", async () => {
fakeTarget.container.querySelector.returns(false);
fakeContainer.getBoundingClientRect.returns({ height: 160 });
await instance._adjustPanelHeight(fakeWindow, fakeContainer);
assert.calledOnce(fakeWindow.document.l10n.translateElements);
assert.calledTwice(fakeContainer.getBoundingClientRect);
assert.calledWithExactly(
fakeContainer.classList.add,
"longMessagePadding"
);
});
it("should reuse the container", () => {
fakeTarget.container.querySelector.returns(true);
@ -358,6 +378,7 @@ describe("BookmarkPanelHub", () => {
querySelector: sandbox.stub().returns({ remove: removeStub }),
},
};
instance._response = { win: fakeWindow };
});
it("should remove the message", () => {
instance.hideMessage(fakeTarget);