From ae1a54bea53f719f8016bb449debf4d712941c46 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, 20 Apr 2022 12:11:04 +0300 Subject: [PATCH] Create BlockUI.spec.js --- src/components/blockui/BlockUI.spec.js | 63 ++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 src/components/blockui/BlockUI.spec.js diff --git a/src/components/blockui/BlockUI.spec.js b/src/components/blockui/BlockUI.spec.js new file mode 100644 index 000000000..0717de401 --- /dev/null +++ b/src/components/blockui/BlockUI.spec.js @@ -0,0 +1,63 @@ +import { config, mount } from '@vue/test-utils'; +import BlockUI from './BlockUI.vue'; +import Panel from '@/components/panel/Panel.vue'; +import Button from '@/components/button/Button.vue'; + +config.global.mocks = { + $primevue: { + config: { + zIndex: { + modal: 1100 + } + } + } +} + +describe('BlockUI.vue', () => { + it('should blocked and unblocked the panel', async () => { + const wrapper = mount({ + template: ` + + + + + +

The story begins as Don Vito Corleone, the head of a New York Mafia family.

+
+
+ `, + components: { + BlockUI, + Panel, + Button + }, + data() { + return { + blockedPanel: false + } + }, + methods: { + blockPanel() { + this.blockedPanel = true; + }, + unblockPanel() { + this.blockedPanel = false; + } + } + }); + + expect(wrapper.find('.p-blockui-container').exists()).toBe(true); + + const buttons = wrapper.findAll('.p-button'); + + await buttons[0].trigger('click'); + + expect(wrapper.find('.p-blockui').exists()).toBe(true); + expect(wrapper.find('.p-blockui').classes()).toContain('p-component-overlay-enter'); + expect(wrapper.find('.p-blockui').attributes().style).toEqual('z-index: 1101;'); + + await buttons[1].trigger('click'); + + expect(wrapper.find('.p-blockui').classes()).toContain('p-component-overlay-leave'); + }); +});