From fa2369e3f05e96306303c32c4d546e58379e2d6b Mon Sep 17 00:00:00 2001 From: Quinn Langille Date: Fri, 19 Oct 2018 15:58:25 -0400 Subject: [PATCH] fix(tests): added new checks to fix reference errors (#287) * fix(tests): added new checks to fix reference errors * feat(test): fixed snapshot * feat(test): fixed snapshot --- .gitignore | 1 + src/Carousel.vue | 4 ++-- src/Pagination.vue | 8 +++++--- src/Slide.vue | 2 +- .../client/components/__snapshots__/carousel.spec.js.snap | 4 ++-- tests/client/components/__snapshots__/slide.spec.js.snap | 2 +- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 09912efb9..04fda1c18 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ logs npm-debug.log* yarn-debug.log* yarn-error.log* +.idea/ # Runtime data pids diff --git a/src/Carousel.vue b/src/Carousel.vue index 535729502..2d510dc30 100644 --- a/src/Carousel.vue +++ b/src/Carousel.vue @@ -840,9 +840,9 @@ export default { // when autoplay direction is backward start from the last slide if (this.autoplayDirection === "backward") { - this.goToLastSlide(); + this.goToLastSlide(); } - }, + }, beforeDestroy() { this.detachMutationObserver(); window.removeEventListener("resize", this.getBrowserWidth); diff --git a/src/Pagination.vue b/src/Pagination.vue index 41c74c244..aa9ffc26d 100644 --- a/src/Pagination.vue +++ b/src/Pagination.vue @@ -26,7 +26,7 @@ width: ${carousel.paginationSize}px; height: ${carousel.paginationSize}px; background: ${isCurrentDot(index) ? carousel.paginationActiveColor : carousel.paginationColor}; - `" + `" > @@ -39,9 +39,11 @@ export default { inject: ["carousel"], computed: { paginationCount() { - return this.carousel.scrollPerPage + return this.carousel && this.carousel.scrollPerPage ? this.carousel.pageCount - : this.carousel.slideCount - 2; + : this.carousel.slideCount + ? this.carousel.slideCount - 2 + : 0; } }, methods: { diff --git a/src/Slide.vue b/src/Slide.vue index 7364e6f48..e0335a723 100644 --- a/src/Slide.vue +++ b/src/Slide.vue @@ -33,7 +33,7 @@ export default { }, computed: { activeSlides() { - const { currentPage, perPage, $children, slideCount } = this.carousel; + const { currentPage, perPage, $children } = this.carousel; const activeSlides = []; const children = $children .filter( diff --git a/tests/client/components/__snapshots__/carousel.spec.js.snap b/tests/client/components/__snapshots__/carousel.spec.js.snap index 16167b4d3..052b30142 100644 --- a/tests/client/components/__snapshots__/carousel.spec.js.snap +++ b/tests/client/components/__snapshots__/carousel.spec.js.snap @@ -76,11 +76,11 @@ exports[`Carousel should decrease current slide number by 1 when advance slide b ".VueCarousel-wrapper .VueCarousel-inner(role='listbox', style='transform: translate(0px, 0); visibility: hidden; height: auto;') .VueCarousel-slide(tabindex='-1') - .VueCarousel-slide(tabindex='-1') + .VueCarousel-slide.VueCarousel-slide-active.VueCarousel-slide-center(tabindex='-1') .VueCarousel-slide(tabindex='-1') .VueCarousel-slide(tabindex='-1') | -.VueCarousel-pagination +.VueCarousel-pagination(style='') ul.VueCarousel-dot-container(role='tablist') li.VueCarousel-dot(aria-hidden='false', role='presentation', aria-selected='false', style='margin-top: 20px; padding: 10px;') button.VueCarousel-dot-button(type='button', role='button', aria-label='\`Item \${index}\`', title='Item 0', tabindex='0', style='width: 10px; height: 10px; background: rgb(239, 239, 239);') diff --git a/tests/client/components/__snapshots__/slide.spec.js.snap b/tests/client/components/__snapshots__/slide.spec.js.snap index b1d6c2901..79b16262c 100644 --- a/tests/client/components/__snapshots__/slide.spec.js.snap +++ b/tests/client/components/__snapshots__/slide.spec.js.snap @@ -3,7 +3,7 @@ exports[`Slide should mount successfully 1`] = ` ".VueCarousel-wrapper .VueCarousel-inner(role='listbox', style='transform: translate(0px, 0); visibility: hidden; height: auto;') - .VueCarousel-slide.VueCarousel-slide-active(tabindex='-1') + .VueCarousel-slide(tabindex='-1') | .VueCarousel-pagination(style='display: none;') ul.VueCarousel-dot-container(role='tablist')