getMcpIconSrc.test.ts50 lines · main
| 1 | import { describe, expect, it } from 'vitest' |
| 2 | |
| 3 | import { getMcpClientIconSrc } from './getMcpIconSrc' |
| 4 | |
| 5 | describe('getMcpClientIconSrc', () => { |
| 6 | it('returns the default icon when only one asset variant exists', () => { |
| 7 | const lightSrc = getMcpClientIconSrc({ |
| 8 | icon: 'cursor', |
| 9 | useDarkVariant: false, |
| 10 | }) |
| 11 | const darkSrc = getMcpClientIconSrc({ |
| 12 | icon: 'cursor', |
| 13 | useDarkVariant: true, |
| 14 | }) |
| 15 | |
| 16 | expect(lightSrc).toBeTruthy() |
| 17 | expect(darkSrc).toBe(lightSrc) |
| 18 | }) |
| 19 | |
| 20 | it('returns the dark icon when a distinct dark variant exists', () => { |
| 21 | const lightSrc = getMcpClientIconSrc({ |
| 22 | icon: 'openai', |
| 23 | useDarkVariant: false, |
| 24 | hasDistinctDarkIcon: true, |
| 25 | }) |
| 26 | const darkSrc = getMcpClientIconSrc({ |
| 27 | icon: 'openai', |
| 28 | useDarkVariant: true, |
| 29 | hasDistinctDarkIcon: true, |
| 30 | }) |
| 31 | |
| 32 | expect(darkSrc).toBeTruthy() |
| 33 | expect(darkSrc).not.toBe(lightSrc) |
| 34 | }) |
| 35 | |
| 36 | it('falls back to the default icon when no distinct dark variant should be used', () => { |
| 37 | const lightSrc = getMcpClientIconSrc({ |
| 38 | icon: 'factory', |
| 39 | useDarkVariant: false, |
| 40 | hasDistinctDarkIcon: true, |
| 41 | }) |
| 42 | const src = getMcpClientIconSrc({ |
| 43 | icon: 'factory', |
| 44 | useDarkVariant: true, |
| 45 | hasDistinctDarkIcon: false, |
| 46 | }) |
| 47 | |
| 48 | expect(src).toBe(lightSrc) |
| 49 | }) |
| 50 | }) |