diff --git a/jest.config.js b/jest.config.js
index 108d78814..35fb25a03 100644
--- a/jest.config.js
+++ b/jest.config.js
@@ -29,5 +29,6 @@ module.exports = {
},
testMatch: [
"**/src/components/**/*.spec.{j,t}s?(x)"
- ]
+ ],
+ timers: "fake"
}
\ No newline at end of file
diff --git a/src/components/message/Message.spec.js b/src/components/message/Message.spec.js
new file mode 100644
index 000000000..78e2707fd
--- /dev/null
+++ b/src/components/message/Message.spec.js
@@ -0,0 +1,52 @@
+import { mount } from '@vue/test-utils';
+import Message from './Message.vue';
+
+describe('Message.vue', () => {
+ let wrapper;
+
+ beforeEach(() => {
+ wrapper = mount(Message, {
+ props: {
+ severity: 'error'
+ },
+ slots: {
+ default: 'Error Message Content'
+ }
+ });
+ });
+
+ it('should exist', () => {
+ expect(wrapper.find('.p-message.p-component').exists()).toBe(true);
+ expect(wrapper.find('.p-message.p-component').classes()).toContain('p-message-error');
+ expect(wrapper.find('.p-message-text').text()).toContain('Error Message Content');
+ });
+
+ it('should close the message', async () => {
+ await wrapper.vm.close({});
+
+ expect(wrapper.vm.visible).toBe(false);
+ expect(wrapper.emitted().close[0]).toEqual([{}]);
+ });
+});
+
+describe('Message.vue', () => {
+ let wrapper;
+
+ beforeEach(() => {
+ wrapper = mount(Message, {
+ props: {
+ severity: 'error',
+ life: 3000,
+ sticky: false
+ },
+ slots: {
+ default: 'Error Message Content'
+ }
+ });
+ });
+
+ it('should sticky and life works', async () => {
+ jest.runTimersToTime(3001);
+ expect(wrapper.vm.visible).toBe(false);
+ });
+});
\ No newline at end of file
diff --git a/src/components/multiselect/MultiSelect.spec.js b/src/components/multiselect/MultiSelect.spec.js
new file mode 100644
index 000000000..7f063b974
--- /dev/null
+++ b/src/components/multiselect/MultiSelect.spec.js
@@ -0,0 +1,78 @@
+import { mount } from '@vue/test-utils';
+import PrimeVue from '@/components/config/PrimeVue';
+import MultiSelect from './MultiSelect.vue';
+
+describe('MultiSelect.vue', () => {
+ let wrapper;
+
+ beforeEach(async () => {
+ wrapper = mount(MultiSelect, {
+ global: {
+ plugins: [PrimeVue],
+ stubs: {
+ teleport: true
+ }
+ },
+ props: {
+ modelValue: null,
+ options: [
+ {name: 'New York', code: 'NY'},
+ {name: 'Rome', code: 'RM'},
+ {name: 'London', code: 'LDN'},
+ {name: 'Istanbul', code: 'IST'},
+ {name: 'Paris', code: 'PRS'}
+ ],
+ optionLabel: 'name',
+ placeholder: 'Select Cities'
+ }
+ });
+
+ await wrapper.vm.onClick({});
+ });
+
+ it('should exist', () => {
+ expect(wrapper.find('.p-multiselect.p-component').exists()).toBe(true);
+ expect(wrapper.find('.p-multiselect-label.p-placeholder').text()).toBe('Select Cities');
+ expect(wrapper.find('.p-multiselect-panel').exists()).toBe(true);
+ expect(wrapper.findAll('li.p-multiselect-item').length).toBe(5);
+ expect(wrapper.findAll('li.p-multiselect-item')[0].attributes()['aria-label']).toBe('New York');
+ expect(wrapper.findAll('li.p-multiselect-item')[0].findAll('span')[1].text()).toBe('New York');
+ });
+
+ it('should select an item', async () => {
+ await wrapper.vm.onOptionSelect({}, wrapper.vm.options[0]);
+
+ expect(wrapper.emitted()['update:modelValue'][0]).toEqual([[wrapper.vm.options[0]]]);
+
+ await wrapper.setProps({ modelValue: [wrapper.vm.options[0]]});
+
+ expect(wrapper.findAll('li.p-multiselect-item')[0].classes()).toContain('p-highlight');
+ expect(wrapper.find('.p-multiselect-label').text()).toBe('New York');
+ });
+
+ it('should select multiple item', async () => {
+ await wrapper.setProps({ modelValue: [wrapper.vm.options[0]]});
+
+ await wrapper.vm.onOptionSelect({}, wrapper.vm.options[1]);
+
+ expect(wrapper.emitted()['update:modelValue'][0]).toEqual([[wrapper.vm.options[0], wrapper.vm.options[1]]]);
+
+ await wrapper.setProps({ modelValue: [wrapper.vm.options[0], wrapper.vm.options[1]]});
+
+ expect(wrapper.findAll('li.p-multiselect-item')[0].classes()).toContain('p-highlight');
+ expect(wrapper.findAll('li.p-multiselect-item')[1].classes()).toContain('p-highlight');
+ });
+
+ it('should close panel', async () => {
+ await wrapper.vm.onCloseClick();
+
+ expect(wrapper.find('.p-multiselect-panel').exists()).toBe(false);
+ });
+
+ it('should chip work', async () => {
+ await wrapper.setProps({ display: 'chip', modelValue: [wrapper.vm.options[0]] });
+
+ expect(wrapper.find('.p-multiselect-token').exists()).toBe(true);
+ expect(wrapper.find('.p-multiselect-token-label').text()).toBe('New York');
+ });
+});
\ No newline at end of file
diff --git a/src/components/orderlist/OrderList.spec.js b/src/components/orderlist/OrderList.spec.js
new file mode 100644
index 000000000..6ca3da0da
--- /dev/null
+++ b/src/components/orderlist/OrderList.spec.js
@@ -0,0 +1,140 @@
+import { mount } from '@vue/test-utils';
+import OrderList from './OrderList.vue';
+
+describe('OrderList.vue', () => {
+ let wrapper;
+
+ beforeEach(() => {
+ wrapper = mount(OrderList, {
+ props: {
+ modelValue: [
+ {
+ "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
+ },
+ {
+ "id": "1004",
+ "code": "h456wer53",
+ "name": "Bracelet",
+ "description": "Product Description",
+ "image": "bracelet.jpg",
+ "price": 15,
+ "category": "Accessories",
+ "quantity": 73,
+ "inventoryStatus": "INSTOCK",
+ "rating": 4
+ },
+ {
+ "id": "1005",
+ "code": "cm230f032",
+ "name": "Gaming Set",
+ "description": "Product Description",
+ "image": "gaming-set.jpg",
+ "price": 299,
+ "category": "Electronics",
+ "quantity": 63,
+ "inventoryStatus": "INSTOCK",
+ "rating": 3
+ }
+ ]
+ },
+ slots: {
+ header: 'List of Products',
+ item: `
+
+ {{slotProps.item.name}}
+
+ {{slotProps.item.category}}
+ \${{slotProps.item.price}}
+ {{slotProps.item.inventoryStatus}}
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt
' + } + }); + }); + + it('should exist', () => { + expect(wrapper.find('.p-panel.p-component').exists()).toBe(true); + expect(wrapper.find('.p-panel-content').text()).toBe('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt'); + expect(wrapper.find('.p-panel-title').text()).toBe('PrimeVue'); + }); + + it('should be toggleable', async () => { + await wrapper.setProps({ toggleable: true }); + + expect(wrapper.find('.p-panel.p-component').classes()).toContain('p-panel-toggleable'); + + await wrapper.vm.toggle({}); + + expect(wrapper.emitted().toggle[0]).toEqual([{originalEvent: {}, value: true}]); + }); +}); \ No newline at end of file