From 3401f4980783f58e9f17dd77ab7f5ed74116f300 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tu=C4=9F=C3=A7e=20K=C3=BC=C3=A7=C3=BCko=C4=9Flu?= Date: Thu, 10 Mar 2022 13:08:56 +0300 Subject: [PATCH] Carousel test added --- src/components/carousel/Carousel.spec.js | 84 ++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 src/components/carousel/Carousel.spec.js diff --git a/src/components/carousel/Carousel.spec.js b/src/components/carousel/Carousel.spec.js new file mode 100644 index 000000000..c324e2f72 --- /dev/null +++ b/src/components/carousel/Carousel.spec.js @@ -0,0 +1,84 @@ +import { mount } from '@vue/test-utils'; +import Carousel from './Carousel.vue'; + +describe('Carousel.vue', () => { + it('should exist', async () => { + const wrapper = mount(Carousel, { + props: { + value: [ + { + "id": "1000", + "code": "vbb124btr", + "name": "Game Controller", + "description": "Product Description", + "image": "game-controller.jpg", + "price": 99, + "category": "Electronics", + "quantity": 2, + "inventoryStatus": "LOWSTOCK", + "rating": 4 + }, + { + "id": "1001", + "code": "nvklal433", + "name": "Black Watch", + "description": "Product Description", + "image": "black-watch.jpg", + "price": 72, + "category": "Accessories", + "quantity": 61, + "inventoryStatus": "INSTOCK", + "rating": 4 + }, + { + "id": "1002", + "code": "zz21cz3c1", + "name": "Blue Band", + "description": "Product Description", + "image": "blue-band.jpg", + "price": 79, + "category": "Fitness", + "quantity": 2, + "inventoryStatus": "LOWSTOCK", + "rating": 3 + }, + { + "id": "1003", + "code": "244wgerg2", + "name": "Blue T-Shirt", + "description": "Product Description", + "image": "blue-t-shirt.jpg", + "price": 29, + "category": "Clothing", + "quantity": 25, + "inventoryStatus": "INSTOCK", + "rating": 5 + } + ] + }, + slots: { + header: 'Basic', + item: ` + ` + } + }); + + expect(wrapper.findAll('.p-carousel-item').length).toBe(4); + + const firstItem = wrapper.findAll('.p-carousel-item')[0]; + expect(firstItem.classes()).toContain('p-carousel-item-active'); + + const nextBtn = wrapper.find('.p-carousel-next'); + await nextBtn.trigger('click'); + + expect(firstItem.classes()).not.toContain('p-carousel-item-active'); + }) +}); \ No newline at end of file