| 9 | ) |
| 10 | |
| 11 | func TestDataURI(t *testing.T) { |
| 12 | tests := []struct { |
| 13 | name string |
| 14 | icon string |
| 15 | theme Theme |
| 16 | wantDataURI bool |
| 17 | wantEmpty bool |
| 18 | }{ |
| 19 | { |
| 20 | name: "light theme icon returns data URI", |
| 21 | icon: "repo", |
| 22 | theme: ThemeLight, |
| 23 | wantDataURI: true, |
| 24 | wantEmpty: false, |
| 25 | }, |
| 26 | { |
| 27 | name: "dark theme icon returns data URI", |
| 28 | icon: "repo", |
| 29 | theme: ThemeDark, |
| 30 | wantDataURI: true, |
| 31 | wantEmpty: false, |
| 32 | }, |
| 33 | { |
| 34 | name: "non-embedded icon returns empty string", |
| 35 | icon: "nonexistent-icon", |
| 36 | theme: ThemeLight, |
| 37 | wantDataURI: false, |
| 38 | wantEmpty: true, |
| 39 | }, |
| 40 | } |
| 41 | |
| 42 | for _, tc := range tests { |
| 43 | t.Run(tc.name, func(t *testing.T) { |
| 44 | result := DataURI(tc.icon, tc.theme) |
| 45 | if tc.wantDataURI { |
| 46 | assert.True(t, strings.HasPrefix(result, "data:image/png;base64,"), "expected data URI prefix") |
| 47 | assert.NotContains(t, result, "https://") |
| 48 | } |
| 49 | if tc.wantEmpty { |
| 50 | assert.Empty(t, result, "expected empty string for non-embedded icon") |
| 51 | } |
| 52 | }) |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | func TestIcons(t *testing.T) { |
| 57 | tests := []struct { |