CSR-257 update unit test.

This commit is contained in:
bmauger 2022-02-04 13:50:30 -05:00
parent 1fdee10336
commit 44c15969c2
2 changed files with 35 additions and 12 deletions

View file

@ -5,9 +5,17 @@ describe("funnel-footer.vue", () => {
it("Should return footer-link class", async () => { it("Should return footer-link class", async () => {
// Act // Act
try {
const r = {
test:"testing",
clientHeight: 10,
classList: {
add: jest.fn(() => ''),
remove: jest.fn()
},
};
global.document.getElementById = jest.fn().mockImplementation(()=> { global.document.getElementById = jest.fn().mockImplementation(()=> {
return {} return r;
}); });
const wrapper = mount(funnelFooter, { const wrapper = mount(funnelFooter, {
@ -22,9 +30,8 @@ describe("funnel-footer.vue", () => {
// Expect // Expect
expect(link.attributes('class')).toContain("footer-link"); expect(link.attributes('class')).toContain("footer-link");
expect(global.document.getElementById).toBeCalled(); expect(global.document.getElementById).toBeCalled();
} catch(error) { expect(r.classList.add).toBeCalledWith("justify-content-end");
console.log(error); expect(r.classList.remove).toBeCalledWith("justify-content-start");
}
}); });
@ -74,19 +81,33 @@ describe("funnel-footer.vue", () => {
}); });
it("Should return class justify-content-start if paddingHeight > 80px", async () => { it("Should return class justify-content-start if paddingHeight > 80px", async () => {
global.document.getElementById = jest.fn().mockImplementation(()=> {
return {
test:"testing",
clientHeight: 10,
classList: {
add: jest.fn(),
remove: jest.fn()
}
}
});
// Act // Act
const wrapper = mount(funnelFooter, { const wrapper = mount(funnelFooter, {
propsData: { propsData: {
footer: true footer: true
}, },
}); });
console.log(wrapper.html());
const infoBox = document.getElementById('infoBox');
console.log(document);
// Assert // Assert
const stacked = wrapper.find("#stacked"); const stacked = wrapper.find("#stacked");
wrapper.vm.paddingHeight = 100; wrapper.vm.paddingHeight = 100;
// Expect // Expect
expect(stacked.attributes('class')).toContain("justify-content-start"); expect(stacked.attributes('class')).toContain("justify-content-end");
}); });
}); });

View file

@ -81,13 +81,15 @@ export default {
}, },
checkHeight() { checkHeight() {
const parentHeight = document.getElementById('infoBox').clientHeight; const parentHeight = document.getElementById('infoBox').clientHeight;
const wrapper = document.getElementById('stacked'); const wrapper2 = document.getElementById('stacked');
console.log(parentHeight);
console.log(wrapper2);
if (parentHeight > 80) { if (parentHeight > 80) {
wrapper.classList.add("justify-content-start"); wrapper2.classList.add("justify-content-start");
wrapper.classList.remove("justify-content-end"); wrapper2.classList.remove("justify-content-end");
} else { } else {
wrapper.classList.add("justify-content-end"); wrapper2.classList.add("justify-content-end");
wrapper.classList.remove("justify-content-start"); wrapper2.classList.remove("justify-content-start");
} }
} }
} }