primevue-mirror/components/blockui/BlockUI.spec.js

64 lines
1.9 KiB
JavaScript
Raw Normal View History

2022-09-06 12:03:37 +00:00
import { config, mount } from '@vue/test-utils';
2022-12-08 14:13:16 +00:00
import Button from 'primevue/button';
import Panel from '../panel/Panel.vue';
2022-09-06 12:03:37 +00:00
import BlockUI from './BlockUI.vue';
config.global.mocks = {
$primevue: {
config: {
zIndex: {
modal: 1100
2022-09-14 14:26:41 +00:00
}
}
2022-09-06 12:03:37 +00:00
}
2022-09-14 11:26:01 +00:00
};
2022-12-08 11:04:25 +00:00
2022-09-06 12:03:37 +00:00
describe('BlockUI.vue', () => {
it('should blocked and unblocked the panel', async () => {
const wrapper = mount({
template: `
<Button type="button" label="Block" @click="blockPanel()"></Button>
<Button type="button" label="Unblock" @click="unblockPanel()"></Button>
<BlockUI :blocked="blockedPanel">
<Panel header="Godfather I" style="margin-top: 20px">
<p>The story begins as Don Vito Corleone, the head of a New York Mafia family.</p>
</Panel>
</BlockUI>
`,
components: {
BlockUI,
Panel,
Button
},
data() {
return {
blockedPanel: false
2022-09-14 11:26:01 +00:00
};
2022-09-06 12:03:37 +00:00
},
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');
});
});