page.test.ts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import { mount } from '@vue/test-utils';
  2. import { describe, expect, it } from 'vitest';
  3. import { Page } from '..';
  4. describe('page.vue', () => {
  5. it('renders title when passed', () => {
  6. const wrapper = mount(Page, {
  7. props: {
  8. title: 'Test Title',
  9. },
  10. });
  11. expect(wrapper.text()).toContain('Test Title');
  12. });
  13. it('renders description when passed', () => {
  14. const wrapper = mount(Page, {
  15. props: {
  16. description: 'Test Description',
  17. },
  18. });
  19. expect(wrapper.text()).toContain('Test Description');
  20. });
  21. it('renders default slot content', () => {
  22. const wrapper = mount(Page, {
  23. slots: {
  24. default: '<p>Default Slot Content</p>',
  25. },
  26. });
  27. expect(wrapper.html()).toContain('<p>Default Slot Content</p>');
  28. });
  29. it('renders footer slot when showFooter is true', () => {
  30. const wrapper = mount(Page, {
  31. props: {
  32. showFooter: true,
  33. },
  34. slots: {
  35. footer: '<p>Footer Slot Content</p>',
  36. },
  37. });
  38. expect(wrapper.html()).toContain('<p>Footer Slot Content</p>');
  39. });
  40. it('applies the custom contentClass', () => {
  41. const wrapper = mount(Page, {
  42. props: {
  43. contentClass: 'custom-class',
  44. },
  45. });
  46. const contentDiv = wrapper.find('.p-4');
  47. expect(contentDiv.classes()).toContain('custom-class');
  48. });
  49. it('does not render title slot if title prop is provided', () => {
  50. const wrapper = mount(Page, {
  51. props: {
  52. title: 'Test Title',
  53. },
  54. slots: {
  55. title: '<p>Title Slot Content</p>',
  56. },
  57. });
  58. expect(wrapper.text()).toContain('Title Slot Content');
  59. expect(wrapper.html()).not.toContain('Test Title');
  60. });
  61. it('does not render description slot if description prop is provided', () => {
  62. const wrapper = mount(Page, {
  63. props: {
  64. description: 'Test Description',
  65. },
  66. slots: {
  67. description: '<p>Description Slot Content</p>',
  68. },
  69. });
  70. expect(wrapper.text()).toContain('Description Slot Content');
  71. expect(wrapper.html()).not.toContain('Test Description');
  72. });
  73. });