Skip to content

Commit

Permalink
removed the console logs
Browse files Browse the repository at this point in the history
  • Loading branch information
pratyushbh committed May 19, 2023
1 parent 338201f commit 83423c8
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
9 changes: 0 additions & 9 deletions __test__/beforeChange.test.js
Expand Up @@ -40,18 +40,9 @@ describe("Slider", function() {
const { container } = render(<SliderWithBeforeChange />);
clickNext(container);
expect(activeSlide(container).textContent).toEqual("slide2");
console.log(
parseInt(getCurrentSlide(container).getAttribute("data-index"))
);
clickNext(container);
expect(activeSlide(container).textContent).toEqual("slide3");
console.log(
parseInt(getCurrentSlide(container).getAttribute("data-index"))
);
clickPrevious(container);
expect(activeSlide(container).textContent).toEqual("slide2");
console.log(
parseInt(getCurrentSlide(container).getAttribute("data-index"))
);
});
});
1 change: 0 additions & 1 deletion __test__/mount/centerMode.test.js
Expand Up @@ -25,7 +25,6 @@ let keys = {
const testsUtil = (settings, actions, keys) => {
const jqDetails = getJQuerySlickDetails(settings, actions, keys);
const reactDetails = getReactSlickDetails(settings, actions, keys);
console.log(reactDetails, jqDetails);
test("checking current slide jQuery vs react", () => {
//currentSlide of react is 1 times more than currentSlide of JQuery
expect(parseInt(reactDetails.currentSlide) - 1).toEqual(
Expand Down
1 change: 1 addition & 0 deletions __test__/mount/lazyLoad.test.js
Expand Up @@ -26,6 +26,7 @@ const testsUtil = (settings, actions, keys) => {
const jqDetails = getJQuerySlickDetails(settings, actions, keys);
const reactDetails = getReactSlickDetails(settings, actions, keys);
test.skip("checking current slide jQuery vs react", () => {
//currentSlide of react is 1 times more than currentSlide of JQuery
expect(parseInt(reactDetails.currentSlide) - 1).toEqual(
parseInt(jqDetails.currentSlide)
);
Expand Down
12 changes: 11 additions & 1 deletion examples/__tests__/MultipleItems.test.js
Expand Up @@ -6,13 +6,16 @@ import {
activeSlides,
clickNext,
clickPrevious,
getActiveButton,
getActiveSlidesCount,
getActiveSlidesText,
getButtons,
getButtonsLength,
getButtonsListItem,
getClonesCount,
getCurrentSlide,
getSlidesCount
getSlidesCount,
hasClass
} from "../../test-utils";
import MultipleItems from "../MultipleItems";

Expand All @@ -35,18 +38,22 @@ describe("Multiple Items", function() {
});
it("should show first 3 slides", function() {
const { container } = render(<MultipleItems />);
expect(getActiveButton(container)).toEqual(["1"]);
expect(getActiveSlidesText(container)).toEqual(["1", "2", "3"]);
// expect(beautify_html(toString(container))).toMatchSnapshot();
});
it("should show slides from 4 to 6 when next button is clicked", function() {
const { container } = render(<MultipleItems />);
clickNext(container);
// Array.from(container.querySelectorAll(".slick-current")).map(e=>console.log(e.textContent))
expect(getActiveButton(container)).toEqual(["2"]);
expect(getActiveSlidesText(container)).toEqual(["4", "5", "6"]);
// expect(beautify_html(toString(container))).toMatchSnapshot();
});
it("should show last 3 slides when previous button is clicked", function() {
const { container } = render(<MultipleItems />);
clickPrevious(container);
expect(getActiveButton(container)).toEqual(["3"]);
expect(getActiveSlidesText(container)).toEqual(["7", "8", "9"]);
// expect(beautify_html(toString(container))).toMatchSnapshot();
});
Expand All @@ -59,6 +66,7 @@ describe("Multiple Items", function() {
cancelable: true
})
);
expect(getActiveButton(container)).toEqual(["1"]);
expect(getActiveSlidesText(container)).toEqual(["1", "2", "3"]);
// expect(beautify_html(toString(container))).toMatchSnapshot();
});
Expand All @@ -71,6 +79,7 @@ describe("Multiple Items", function() {
cancelable: true
})
);
expect(getActiveButton(container)).toEqual(["2"]);
expect(getActiveSlidesText(container)).toEqual(["4", "5", "6"]);
// expect(beautify_html(toString(container))).toMatchSnapshot();
});
Expand All @@ -83,6 +92,7 @@ describe("Multiple Items", function() {
cancelable: true
})
);
expect(getActiveButton(container)).toEqual(["3"]);
expect(getActiveSlidesText(container)).toEqual(["7", "8", "9"]);
// expect(beautify_html(toString(container))).toMatchSnapshot();
});
Expand Down
5 changes: 5 additions & 0 deletions test-utils.js
Expand Up @@ -36,6 +36,11 @@ export function hasClass(element, classname) {
}
return false;
}
export function getActiveButton(container) {
return Array.from(
container.querySelectorAll(".slick-dots .slick-active button")
).map(e => e.textContent);
}
export function getCurrentSlideIdState(container) {
return parseInt(getCurrentSlide(container).getAttribute("data-index")) + 1;
}
Expand Down

0 comments on commit 83423c8

Please sign in to comment.