From cb91a61b0d4e90455c4dbee38a0ef68e716a967e 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: Wed, 6 Apr 2022 16:36:08 +0300 Subject: [PATCH] Create Timeline.spec.js --- src/components/timeline/Timeline.spec.js | 83 ++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 src/components/timeline/Timeline.spec.js diff --git a/src/components/timeline/Timeline.spec.js b/src/components/timeline/Timeline.spec.js new file mode 100644 index 000000000..c5c9b422d --- /dev/null +++ b/src/components/timeline/Timeline.spec.js @@ -0,0 +1,83 @@ +import { mount } from '@vue/test-utils'; +import Timeline from './Timeline.vue'; + +describe('Timeline.vue', () => { + let wrapper; + + beforeEach(() => { + wrapper = mount(Timeline, { + props: { + value: [ + {status: 'Ordered', date: '15/10/2020 10:30', icon: 'pi pi-shopping-cart', color: '#9C27B0', image: 'game-controller.jpg'}, + {status: 'Processing', date: '15/10/2020 14:00', icon: 'pi pi-cog', color: '#673AB7'}, + {status: 'Shipped', date: '15/10/2020 16:15', icon: 'pi pi-shopping-cart', color: '#FF9800'}, + {status: 'Delivered', date: '16/10/2020 10:00', icon: 'pi pi-check', color: '#607D8B'} + ] + }, + slots: { + content: ` + + ` + } + }); + }); + + it('should exist', () => { + expect(wrapper.find('.p-timeline.p-component').exists()).toBe(true); + expect(wrapper.find('.p-timeline').classes()).toContain('p-timeline-left'); + expect(wrapper.find('.p-timeline').classes()).toContain('p-timeline-vertical'); + expect(wrapper.findAll('.p-timeline-event-separator').length).toBe(4); + }); + + it('should align right', async () => { + await wrapper.setProps({ align: 'right' }); + + expect(wrapper.find('.p-timeline').classes()).toContain('p-timeline-right'); + }); + + it('should horizontal layout', async () => { + await wrapper.setProps({ layout: 'horizontal' }); + + expect(wrapper.find('.p-timeline').classes()).toContain('p-timeline-horizontal'); + }); +}); + +describe('customized timeline', () => { + let wrapper; + + beforeEach(() => { + wrapper = mount(Timeline, { + slots: { + opposite: ` + + `, + marker: ` + + ` + }, + props: { + value: [ + {status: 'Ordered', date: '15/10/2020 10:30', icon: 'pi pi-shopping-cart', color: '#9C27B0', image: 'game-controller.jpg'}, + {status: 'Processing', date: '15/10/2020 14:00', icon: 'pi pi-cog', color: '#673AB7'}, + {status: 'Shipped', date: '15/10/2020 16:15', icon: 'pi pi-shopping-cart', color: '#FF9800'}, + {status: 'Delivered', date: '16/10/2020 10:00', icon: 'pi pi-check', color: '#607D8B'} + ] + } + }); + }); + + it('should have templating', () => { + const firstItem = wrapper.findAll('.p-timeline-event')[0]; + + expect(firstItem.find('.p-text-secondary').text()).toBe('15/10/2020 10:30'); + expect(firstItem.find('.custom-marker').attributes().style.backgroundColor).not.toBe(''); + }); +}); \ No newline at end of file