Skip to content

Commit 1920e2b

Browse files
test(theme): cover editor_colors QueryaEditorTheme mapping
Closes #101.
1 parent f46b336 commit 1920e2b

1 file changed

Lines changed: 61 additions & 0 deletions

File tree

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import 'dart:io';
2+
3+
import 'package:flutter_test/flutter_test.dart';
4+
import 'package:querya_desktop/core/theme/parser/color_parser.dart';
5+
import 'package:querya_desktop/core/theme/parser/querya_editor_theme_from_manifest.dart';
6+
import 'package:querya_desktop/core/theme/parser/querya_theme_manifest.dart';
7+
import 'package:querya_desktop/core/theme/querya_theme.dart';
8+
9+
void main() {
10+
group('editorThemeFromQueryaColors', () {
11+
test('full fixture maps custom editor values', () {
12+
final raw =
13+
File('test/fixtures/themes/querya_custom_dark.json').readAsStringSync();
14+
final manifest = QueryaThemeManifest.fromJsonString(raw);
15+
final editor = editorThemeFromQueryaColors(
16+
colors: manifest.editorColors,
17+
fallback: QueryaTheme.darkDefault.editor,
18+
);
19+
20+
expect(editor.background, parseQueryaThemeColor('#0F1117'));
21+
expect(editor.foreground, parseQueryaThemeColor('#E2E8F0'));
22+
expect(editor.selection, parseQueryaThemeColor('#264F78'));
23+
expect(editor.lineNumber, parseQueryaThemeColor('#64748B'));
24+
expect(editor.widgetBorder, parseQueryaThemeColor('#38BDF866'));
25+
expect(editor.keyword, parseQueryaThemeColor('#569CD6'));
26+
});
27+
28+
test('minimal fixture falls back for missing editor fields', () {
29+
final raw = File('test/fixtures/themes/querya_custom_minimal.json')
30+
.readAsStringSync();
31+
final manifest = QueryaThemeManifest.fromJsonString(raw);
32+
final fallback = QueryaTheme.darkDefault.editor;
33+
final editor = editorThemeFromQueryaColors(
34+
colors: manifest.editorColors,
35+
fallback: fallback,
36+
);
37+
38+
expect(editor.background, parseQueryaThemeColor('#010203'));
39+
expect(editor.foreground, fallback.foreground);
40+
expect(editor.selection, fallback.selection);
41+
expect(editor.comment, fallback.comment);
42+
expect(editor.widgetBorder, fallback.widgetBorder);
43+
});
44+
45+
test('invalid optional color uses fallback value', () {
46+
final fallback = QueryaTheme.darkDefault.editor;
47+
final editor = editorThemeFromQueryaColors(
48+
colors: const {
49+
'background': '#0F1117',
50+
'selection': 'bad-color',
51+
'keyword': 'ZZZZZZ',
52+
},
53+
fallback: fallback,
54+
);
55+
56+
expect(editor.background, parseQueryaThemeColor('#0F1117'));
57+
expect(editor.selection, fallback.selection);
58+
expect(editor.keyword, fallback.keyword);
59+
});
60+
});
61+
}

0 commit comments

Comments
 (0)