|
| 1 | +import { describe, it, expect, beforeEach } from 'vitest'; |
| 2 | +import { render, screen } from '@testing-library/react'; |
| 3 | +import Loading from './loading'; |
| 4 | + |
| 5 | +describe('Loading - Responsive Multi-device Columns & Mobile Viewport Layouts', () => { |
| 6 | + beforeEach(() => { |
| 7 | + Object.defineProperty(window, 'innerWidth', { |
| 8 | + writable: true, |
| 9 | + configurable: true, |
| 10 | + value: 375, |
| 11 | + }); |
| 12 | + }); |
| 13 | + |
| 14 | + it('renders correctly on a mobile-width viewport', () => { |
| 15 | + const { container } = render(<Loading />); |
| 16 | + |
| 17 | + expect(container.firstChild).toBeTruthy(); |
| 18 | + }); |
| 19 | + |
| 20 | + it('uses a vertical flex layout suitable for mobile screens', () => { |
| 21 | + const { container } = render(<Loading />); |
| 22 | + |
| 23 | + const contentWrapper = container.querySelector('.flex-col'); |
| 24 | + |
| 25 | + expect(contentWrapper).toBeTruthy(); |
| 26 | + }); |
| 27 | + |
| 28 | + it('keeps content centered within the viewport', () => { |
| 29 | + const { container } = render(<Loading />); |
| 30 | + |
| 31 | + const wrapper = container.querySelector('.min-h-screen'); |
| 32 | + |
| 33 | + expect(wrapper?.className).toContain('items-center'); |
| 34 | + expect(wrapper?.className).toContain('justify-center'); |
| 35 | + }); |
| 36 | + |
| 37 | + it('does not use fixed-width container classes that could cause horizontal scrolling', () => { |
| 38 | + const { container } = render(<Loading />); |
| 39 | + |
| 40 | + const root = container.firstElementChild; |
| 41 | + |
| 42 | + expect(root?.className).not.toContain('w-screen'); |
| 43 | + expect(root?.className).not.toContain('max-w'); |
| 44 | + }); |
| 45 | + |
| 46 | + it('renders the loading spinner on mobile layouts', () => { |
| 47 | + const { container } = render(<Loading />); |
| 48 | + |
| 49 | + const spinner = container.querySelector('.animate-spin'); |
| 50 | + |
| 51 | + expect(spinner).toBeTruthy(); |
| 52 | + }); |
| 53 | +}); |
0 commit comments