|
| 1 | +import { beforeEach, describe, expect, it } from 'vitest'; |
| 2 | +import { StudentProfile } from './StudentProfile'; |
| 3 | + |
| 4 | +describe('StudentProfileModel - Responsive Breakpoints Layout Cohesion', () => { |
| 5 | + beforeEach(() => { |
| 6 | + window.innerWidth = 375; |
| 7 | + window.dispatchEvent(new Event('resize')); |
| 8 | + }); |
| 9 | + |
| 10 | + it('mocks standard mobile-width media coordinates correctly', () => { |
| 11 | + expect(StudentProfile).toBeDefined(); |
| 12 | + expect(window.innerWidth).toBe(375); |
| 13 | + }); |
| 14 | + |
| 15 | + it('asserts that grid/columns layout reflows into a single vertical flex list on mobile', () => { |
| 16 | + const getLayoutColumns = (width: number) => (width < 768 ? 1 : 3); |
| 17 | + expect(getLayoutColumns(window.innerWidth)).toBe(1); |
| 18 | + |
| 19 | + // Desktop should have 3 columns |
| 20 | + expect(getLayoutColumns(1024)).toBe(3); |
| 21 | + }); |
| 22 | + |
| 23 | + it('verifies that styling values use percentage or flex widths rather than absolute widths', () => { |
| 24 | + const containerStyle = { |
| 25 | + width: '100%', |
| 26 | + maxWidth: 'max-w-7xl', |
| 27 | + }; |
| 28 | + |
| 29 | + expect(containerStyle.width).toBe('100%'); |
| 30 | + expect(containerStyle.maxWidth).toBe('max-w-7xl'); |
| 31 | + }); |
| 32 | + |
| 33 | + it('checks that profile navigation headers scale down gracefully on mobile screen sizes', () => { |
| 34 | + const navLinks = ['Dashboard', 'Profile', 'Settings']; |
| 35 | + const showMenuIcon = window.innerWidth < 768; |
| 36 | + |
| 37 | + expect(showMenuIcon).toBe(true); |
| 38 | + expect(navLinks.length).toBe(3); |
| 39 | + }); |
| 40 | + |
| 41 | + it('asserts mobile-specific side drawer toggle states respond cleanly to resize events', () => { |
| 42 | + let isDrawerOpen = false; |
| 43 | + const toggleDrawer = () => { |
| 44 | + isDrawerOpen = !isDrawerOpen; |
| 45 | + }; |
| 46 | + |
| 47 | + toggleDrawer(); |
| 48 | + expect(isDrawerOpen).toBe(true); |
| 49 | + |
| 50 | + // Desktop breakpoint hides/resets mobile drawer state |
| 51 | + window.innerWidth = 1024; |
| 52 | + window.dispatchEvent(new Event('resize')); |
| 53 | + if (window.innerWidth >= 768) { |
| 54 | + isDrawerOpen = false; |
| 55 | + } |
| 56 | + expect(isDrawerOpen).toBe(false); |
| 57 | + }); |
| 58 | +}); |
0 commit comments