|
| 1 | +import { describe, expect, it } from 'vitest'; |
| 2 | +import { STATE_DESCRIPTIONS, STYLING_DESCRIPTIONS } from '../config/defaults'; |
| 3 | +import { StateManagementSchema, StylingSchema } from '../config/schema'; |
| 4 | + |
| 5 | +/** |
| 6 | + * Tests for conditional prompts logic |
| 7 | + * These tests verify the configuration and validation for runtime-dependent styling options |
| 8 | + */ |
| 9 | +describe('Conditional Prompts Configuration', () => { |
| 10 | + describe('Styling options', () => { |
| 11 | + it('should have all 4 styling options defined', () => { |
| 12 | + const stylingValues = StylingSchema.options; |
| 13 | + |
| 14 | + expect(stylingValues).toContain('css'); |
| 15 | + expect(stylingValues).toContain('tailwind'); |
| 16 | + expect(stylingValues).toContain('styled-components'); |
| 17 | + expect(stylingValues).toContain('css-modules'); |
| 18 | + expect(stylingValues).toHaveLength(4); |
| 19 | + }); |
| 20 | + |
| 21 | + it('should have descriptions for all styling options', () => { |
| 22 | + expect(STYLING_DESCRIPTIONS.css).toBeDefined(); |
| 23 | + expect(STYLING_DESCRIPTIONS.tailwind).toBeDefined(); |
| 24 | + expect(STYLING_DESCRIPTIONS['styled-components']).toBeDefined(); |
| 25 | + expect(STYLING_DESCRIPTIONS['css-modules']).toBeDefined(); |
| 26 | + }); |
| 27 | + |
| 28 | + it('Vite should support all 4 styling options', () => { |
| 29 | + // For Vite, all 4 options should be valid |
| 30 | + const viteOptions = ['tailwind', 'styled-components', 'css-modules', 'css']; |
| 31 | + |
| 32 | + viteOptions.forEach((option) => { |
| 33 | + const result = StylingSchema.safeParse(option); |
| 34 | + expect(result.success).toBe(true); |
| 35 | + }); |
| 36 | + }); |
| 37 | + |
| 38 | + it('Next.js should use tailwind (auto-selected)', () => { |
| 39 | + // For Next.js, tailwind is auto-selected |
| 40 | + const nextjsDefault = 'tailwind'; |
| 41 | + const result = StylingSchema.safeParse(nextjsDefault); |
| 42 | + |
| 43 | + expect(result.success).toBe(true); |
| 44 | + }); |
| 45 | + }); |
| 46 | + |
| 47 | + describe('State management options', () => { |
| 48 | + it('should have all state management options including jotai', () => { |
| 49 | + const stateValues = StateManagementSchema.options; |
| 50 | + |
| 51 | + expect(stateValues).toContain('none'); |
| 52 | + expect(stateValues).toContain('redux'); |
| 53 | + expect(stateValues).toContain('zustand'); |
| 54 | + expect(stateValues).toContain('jotai'); |
| 55 | + expect(stateValues).toHaveLength(4); |
| 56 | + }); |
| 57 | + |
| 58 | + it('should have descriptions for all state management options', () => { |
| 59 | + expect(STATE_DESCRIPTIONS.none).toBeDefined(); |
| 60 | + expect(STATE_DESCRIPTIONS.redux).toBeDefined(); |
| 61 | + expect(STATE_DESCRIPTIONS.zustand).toBeDefined(); |
| 62 | + expect(STATE_DESCRIPTIONS.jotai).toBeDefined(); |
| 63 | + }); |
| 64 | + |
| 65 | + it('should validate jotai as a valid state management option', () => { |
| 66 | + const result = StateManagementSchema.safeParse('jotai'); |
| 67 | + expect(result.success).toBe(true); |
| 68 | + }); |
| 69 | + }); |
| 70 | + |
| 71 | + describe('Styling choices logic', () => { |
| 72 | + /** |
| 73 | + * Helper to get styling choices based on runtime |
| 74 | + */ |
| 75 | + function getStylingChoicesForRuntime(runtime: 'vite' | 'nextjs'): string[] { |
| 76 | + if (runtime === 'vite') { |
| 77 | + return ['tailwind', 'styled-components', 'css-modules', 'css']; |
| 78 | + } |
| 79 | + // Next.js auto-selects tailwind |
| 80 | + return ['tailwind']; |
| 81 | + } |
| 82 | + |
| 83 | + it('should return 4 styling options for Vite', () => { |
| 84 | + const choices = getStylingChoicesForRuntime('vite'); |
| 85 | + |
| 86 | + expect(choices).toHaveLength(4); |
| 87 | + expect(choices).toContain('tailwind'); |
| 88 | + expect(choices).toContain('styled-components'); |
| 89 | + expect(choices).toContain('css-modules'); |
| 90 | + expect(choices).toContain('css'); |
| 91 | + }); |
| 92 | + |
| 93 | + it('should return only tailwind for Next.js', () => { |
| 94 | + const choices = getStylingChoicesForRuntime('nextjs'); |
| 95 | + |
| 96 | + expect(choices).toHaveLength(1); |
| 97 | + expect(choices).toContain('tailwind'); |
| 98 | + }); |
| 99 | + }); |
| 100 | +}); |
| 101 | + |
0 commit comments