|
1 | 1 | import { describe, test, expect, mock } from 'bun:test' |
2 | 2 |
|
| 3 | +import { getInputModeConfig } from '../utils/input-modes' |
| 4 | + |
3 | 5 | import type { InputMode } from '../utils/input-modes' |
4 | 6 |
|
5 | 7 | /** |
@@ -353,81 +355,58 @@ describe('referral-mode', () => { |
353 | 355 | }) |
354 | 356 |
|
355 | 357 | test('input width is adjusted in referral mode for icon column', () => { |
356 | | - const baseInputWidth = 100 |
357 | | - const inputMode = 'referral' as InputMode |
| 358 | + const referralConfig = getInputModeConfig('referral') |
358 | 359 |
|
359 | | - // Width should be reduced by 2 to account for '◎' icon and spacing |
360 | | - const widthAdjustment = inputMode === 'referral' ? 2 : 0 |
361 | | - const adjustedInputWidth = baseInputWidth - widthAdjustment |
362 | | - |
363 | | - expect(adjustedInputWidth).toBe(98) |
| 360 | + expect(referralConfig.widthAdjustment).toBeGreaterThan(0) |
364 | 361 | }) |
365 | 362 |
|
366 | 363 | test('input width is NOT adjusted when not in referral mode', () => { |
367 | | - const baseInputWidth = 100 |
368 | | - const inputMode = 'default' as InputMode |
| 364 | + const defaultConfig = getInputModeConfig('default') |
369 | 365 |
|
370 | | - const widthAdjustment = inputMode === 'referral' ? 2 : 0 |
371 | | - const adjustedInputWidth = baseInputWidth - widthAdjustment |
372 | | - |
373 | | - expect(adjustedInputWidth).toBe(100) |
| 366 | + expect(defaultConfig.widthAdjustment).toBe(0) |
374 | 367 | }) |
375 | 368 |
|
376 | 369 | test('placeholder changes in referral mode', () => { |
377 | | - const normalPlaceholder = 'type a message...' |
378 | | - const referralPlaceholder = 'enter referral code (e.g. ref-abc123)...' |
379 | | - const inputMode = 'referral' as InputMode |
| 370 | + const defaultConfig = getInputModeConfig('default') |
| 371 | + const referralConfig = getInputModeConfig('referral') |
380 | 372 |
|
381 | | - const effectivePlaceholder = |
382 | | - inputMode === 'referral' ? referralPlaceholder : normalPlaceholder |
383 | | - |
384 | | - expect(effectivePlaceholder).toBe('enter referral code (e.g. ref-abc123)...') |
| 373 | + expect(referralConfig.placeholder).not.toBe(defaultConfig.placeholder) |
385 | 374 | }) |
386 | 375 |
|
387 | | - test('placeholder is normal when not in referral mode', () => { |
388 | | - const normalPlaceholder = 'type a message...' |
389 | | - const referralPlaceholder = 'enter referral code (e.g. ref-abc123)...' |
390 | | - const inputMode = 'default' as InputMode |
| 376 | + test('referral mode has a placeholder', () => { |
| 377 | + const referralConfig = getInputModeConfig('referral') |
391 | 378 |
|
392 | | - const effectivePlaceholder = |
393 | | - inputMode === 'referral' ? referralPlaceholder : normalPlaceholder |
394 | | - |
395 | | - expect(effectivePlaceholder).toBe('type a message...') |
| 379 | + expect(referralConfig.placeholder.length).toBeGreaterThan(0) |
396 | 380 | }) |
397 | 381 |
|
398 | 382 | test('icon is displayed in referral mode', () => { |
399 | | - const inputMode = 'referral' as InputMode |
400 | | - const icon = inputMode === 'referral' ? '◎' : null |
| 383 | + const referralConfig = getInputModeConfig('referral') |
401 | 384 |
|
402 | | - expect(icon).toBe('◎') |
| 385 | + expect(referralConfig.icon).not.toBeNull() |
403 | 386 | }) |
404 | 387 |
|
405 | 388 | test('no icon is displayed in default mode', () => { |
406 | | - const inputMode = 'default' as InputMode |
407 | | - const icon = inputMode === 'referral' ? '◎' : null |
| 389 | + const defaultConfig = getInputModeConfig('default') |
408 | 390 |
|
409 | | - expect(icon).toBe(null) |
| 391 | + expect(defaultConfig.icon).toBeNull() |
410 | 392 | }) |
411 | 393 |
|
412 | 394 | test('border color changes to warning in referral mode', () => { |
413 | | - const inputMode = 'referral' as InputMode |
414 | | - const color = inputMode === 'referral' ? 'warning' : 'foreground' |
| 395 | + const referralConfig = getInputModeConfig('referral') |
415 | 396 |
|
416 | | - expect(color).toBe('warning') |
| 397 | + expect(referralConfig.color).toBe('warning') |
417 | 398 | }) |
418 | 399 |
|
419 | 400 | test('agent mode toggle is hidden in referral mode', () => { |
420 | | - const inputMode = 'referral' as InputMode |
421 | | - const showAgentModeToggle = inputMode === 'default' |
| 401 | + const referralConfig = getInputModeConfig('referral') |
422 | 402 |
|
423 | | - expect(showAgentModeToggle).toBe(false) |
| 403 | + expect(referralConfig.showAgentModeToggle).toBe(false) |
424 | 404 | }) |
425 | 405 |
|
426 | 406 | test('agent mode toggle is shown in default mode', () => { |
427 | | - const inputMode = 'default' as InputMode |
428 | | - const showAgentModeToggle = inputMode === 'default' |
| 407 | + const defaultConfig = getInputModeConfig('default') |
429 | 408 |
|
430 | | - expect(showAgentModeToggle).toBe(true) |
| 409 | + expect(defaultConfig.showAgentModeToggle).toBe(true) |
431 | 410 | }) |
432 | 411 | }) |
433 | 412 |
|
@@ -472,10 +451,9 @@ describe('referral-mode', () => { |
472 | 451 | }) |
473 | 452 |
|
474 | 453 | test('slash suggestions are disabled in referral mode', () => { |
475 | | - const inputMode = 'referral' as InputMode |
476 | | - const disableSlashSuggestions = inputMode !== 'default' |
| 454 | + const referralConfig = getInputModeConfig('referral') |
477 | 455 |
|
478 | | - expect(disableSlashSuggestions).toBe(true) |
| 456 | + expect(referralConfig.disableSlashSuggestions).toBe(true) |
479 | 457 | }) |
480 | 458 | }) |
481 | 459 |
|
|
0 commit comments