auto-translate-json-library 1.5.5 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.MD +1141 -148
- package/build/package.json +96 -22
- package/build/src/aws.d.ts +1 -1
- package/build/src/aws.js +27 -38
- package/build/src/azure.d.ts +1 -1
- package/build/src/azure.js +50 -64
- package/build/src/bin/cli.d.ts +1 -1
- package/build/src/bin/cli.js +196 -37
- package/build/src/config.d.ts +1 -0
- package/build/src/config.js +1 -2
- package/build/src/deepl.d.ts +1 -1
- package/build/src/deepl.js +18 -64
- package/build/src/files.d.ts +11 -2
- package/build/src/files.js +356 -69
- package/build/src/folderFiles.d.ts +6 -3
- package/build/src/folderFiles.js +33 -44
- package/build/src/format/arb-handler.d.ts +33 -0
- package/build/src/format/arb-handler.js +679 -0
- package/build/src/format/base-format-handler.d.ts +75 -0
- package/build/src/format/base-format-handler.js +166 -0
- package/build/src/format/csv-handler.d.ts +38 -0
- package/build/src/format/csv-handler.js +604 -0
- package/build/src/format/index.d.ts +17 -0
- package/build/src/format/index.js +48 -0
- package/build/src/format/json-handler.d.ts +17 -0
- package/build/src/format/json-handler.js +294 -0
- package/build/src/format/po-handler.d.ts +17 -0
- package/build/src/format/po-handler.js +338 -0
- package/build/src/format/po-utils.d.ts +86 -0
- package/build/src/format/po-utils.js +385 -0
- package/build/src/format/pot-handler.d.ts +22 -0
- package/build/src/format/pot-handler.js +331 -0
- package/build/src/format/properties-handler.d.ts +26 -0
- package/build/src/format/properties-handler.js +500 -0
- package/build/src/format/tsv-handler.d.ts +13 -0
- package/build/src/format/tsv-handler.js +67 -0
- package/build/src/format/xliff-handler.d.ts +24 -0
- package/build/src/format/xliff-handler.js +433 -0
- package/build/src/format/xmb-handler.d.ts +33 -0
- package/build/src/format/xmb-handler.js +484 -0
- package/build/src/format/xmb-xtb-utils.d.ts +43 -0
- package/build/src/format/xmb-xtb-utils.js +180 -0
- package/build/src/format/xml-handler.d.ts +28 -0
- package/build/src/format/xml-handler.js +561 -0
- package/build/src/format/xtb-handler.d.ts +33 -0
- package/build/src/format/xtb-handler.js +518 -0
- package/build/src/format/yaml-handler.d.ts +26 -0
- package/build/src/format/yaml-handler.js +522 -0
- package/build/src/format-detector.d.ts +7 -0
- package/build/src/format-detector.js +58 -0
- package/build/src/format-handler-factory.d.ts +9 -0
- package/build/src/format-handler-factory.js +18 -0
- package/build/src/format.interface.d.ts +56 -0
- package/build/src/format.interface.js +1 -0
- package/build/src/google.d.ts +1 -1
- package/build/src/google.js +32 -49
- package/build/src/index.d.ts +4 -3
- package/build/src/index.js +15 -17
- package/build/src/lib.d.ts +1 -1
- package/build/src/lib.js +188 -133
- package/build/src/openai.d.ts +2 -2
- package/build/src/openai.js +59 -50
- package/build/src/translate.interface.d.ts +1 -1
- package/build/src/translate.interface.js +1 -2
- package/build/src/util.js +4 -9
- package/build/src/validation/enhanced-validation-result.d.ts +96 -0
- package/build/src/validation/enhanced-validation-result.js +198 -0
- package/build/src/validation/error-messages.d.ts +88 -0
- package/build/src/validation/error-messages.js +436 -0
- package/build/src/validation/error-recovery.d.ts +78 -0
- package/build/src/validation/error-recovery.js +593 -0
- package/build/src/validation/example-usage.d.ts +31 -0
- package/build/src/validation/example-usage.js +148 -0
- package/build/src/validation/format-rules.d.ts +37 -0
- package/build/src/validation/format-rules.js +550 -0
- package/build/src/validation/format-validator.d.ts +70 -0
- package/build/src/validation/format-validator.js +279 -0
- package/build/src/validation/index.d.ts +13 -0
- package/build/src/validation/index.js +30 -0
- package/build/src/validation/validation-service.d.ts +56 -0
- package/build/src/validation/validation-service.js +262 -0
- package/build/tests/arb-handler.test.d.ts +1 -0
- package/build/tests/arb-handler.test.js +694 -0
- package/build/tests/cli-integration.test.d.ts +1 -0
- package/build/tests/cli-integration.test.js +352 -0
- package/build/tests/csv-handler.test.d.ts +1 -0
- package/build/tests/csv-handler.test.js +507 -0
- package/build/tests/error-handling.test.d.ts +1 -0
- package/build/tests/error-handling.test.js +456 -0
- package/build/tests/files-integration.test.d.ts +1 -0
- package/build/tests/files-integration.test.js +421 -0
- package/build/tests/json-handler.test.d.ts +1 -0
- package/build/tests/json-handler.test.js +526 -0
- package/build/tests/po-handler.test.d.ts +1 -0
- package/build/tests/po-handler.test.js +768 -0
- package/build/tests/properties-handler.test.d.ts +1 -0
- package/build/tests/properties-handler.test.js +316 -0
- package/build/tests/setup.d.ts +1 -0
- package/build/tests/setup.js +5 -0
- package/build/tests/xliff-handler.test.d.ts +1 -0
- package/build/tests/xliff-handler.test.js +459 -0
- package/build/tests/xmb-xtb-handler.test.d.ts +1 -0
- package/build/tests/xmb-xtb-handler.test.js +758 -0
- package/build/tests/xml-handler.test.d.ts +1 -0
- package/build/tests/xml-handler.test.js +570 -0
- package/build/tests/yaml-handler.test.d.ts +1 -0
- package/build/tests/yaml-handler.test.js +156 -0
- package/package.json +96 -22
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { PropertiesHandler } from "../src/format/properties-handler.js";
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
import { dirname } from 'path';
|
|
4
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
5
|
+
const __dirname = dirname(__filename);
|
|
6
|
+
import * as fs from "node:fs";
|
|
7
|
+
import * as path from "node:path";
|
|
8
|
+
describe("PropertiesHandler", () => {
|
|
9
|
+
let handler;
|
|
10
|
+
let samplePropertiesContent;
|
|
11
|
+
let unicodeEscapedContent;
|
|
12
|
+
let placeholdersContent;
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
handler = new PropertiesHandler();
|
|
15
|
+
samplePropertiesContent = fs.readFileSync(path.join(__dirname, "test-data", "sample.properties"), "utf-8");
|
|
16
|
+
unicodeEscapedContent = fs.readFileSync(path.join(__dirname, "test-data", "unicode-escaped.properties"), "utf-8");
|
|
17
|
+
placeholdersContent = fs.readFileSync(path.join(__dirname, "test-data", "placeholders.properties"), "utf-8");
|
|
18
|
+
});
|
|
19
|
+
describe("canHandle", () => {
|
|
20
|
+
it("should handle .properties files", () => {
|
|
21
|
+
expect(handler.canHandle("test.properties")).toBe(true);
|
|
22
|
+
expect(handler.canHandle("messages.properties")).toBe(true);
|
|
23
|
+
});
|
|
24
|
+
it("should not handle non-properties files", () => {
|
|
25
|
+
expect(handler.canHandle("test.json")).toBe(false);
|
|
26
|
+
expect(handler.canHandle("test.xml")).toBe(false);
|
|
27
|
+
expect(handler.canHandle("test.yaml")).toBe(false);
|
|
28
|
+
});
|
|
29
|
+
it("should validate Properties content when provided", () => {
|
|
30
|
+
expect(handler.canHandle("test.properties", "key=value")).toBe(true);
|
|
31
|
+
expect(handler.canHandle("test.properties", "key: value")).toBe(true);
|
|
32
|
+
expect(handler.canHandle("test.properties", "key=value\nother=value")).toBe(true);
|
|
33
|
+
// Properties parser is quite permissive, empty content is valid
|
|
34
|
+
expect(handler.canHandle("test.properties", "")).toBe(true);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
describe("parse", () => {
|
|
38
|
+
it("should parse valid Properties content", () => {
|
|
39
|
+
const result = handler.parse(samplePropertiesContent);
|
|
40
|
+
expect(result).toBeDefined();
|
|
41
|
+
expect(result._metadata).toBeDefined();
|
|
42
|
+
expect(result._metadata?.format).toBe("properties");
|
|
43
|
+
expect(result._metadata?.encoding).toBeDefined();
|
|
44
|
+
});
|
|
45
|
+
it("should parse basic key-value pairs", () => {
|
|
46
|
+
const result = handler.parse(samplePropertiesContent);
|
|
47
|
+
expect(result["app.name"]).toBe("My Application");
|
|
48
|
+
expect(result["app.version"]).toBe("1.0.0");
|
|
49
|
+
expect(result["app.description"]).toBe("This is a sample application");
|
|
50
|
+
expect(result["navigation.home"]).toBe("Home");
|
|
51
|
+
expect(result["navigation.about"]).toBe("About");
|
|
52
|
+
expect(result["navigation.contact"]).toBe("Contact");
|
|
53
|
+
});
|
|
54
|
+
it("should preserve comments in metadata", () => {
|
|
55
|
+
const result = handler.parse(samplePropertiesContent);
|
|
56
|
+
expect(result._metadata?.comments).toBeDefined();
|
|
57
|
+
expect(result._metadata?.preserveComments).toBe(true);
|
|
58
|
+
});
|
|
59
|
+
it("should preserve formatting information", () => {
|
|
60
|
+
const result = handler.parse(samplePropertiesContent);
|
|
61
|
+
expect(result._metadata?.formatting).toBeDefined();
|
|
62
|
+
expect(result._metadata?.formatting?.separators).toBeDefined();
|
|
63
|
+
});
|
|
64
|
+
it("should detect encoding correctly", () => {
|
|
65
|
+
const result = handler.parse(samplePropertiesContent);
|
|
66
|
+
expect(result._metadata?.encoding).toBe("UTF-8");
|
|
67
|
+
const unicodeResult = handler.parse(unicodeEscapedContent);
|
|
68
|
+
expect(unicodeResult._metadata?.encoding).toBe("ISO-8859-1");
|
|
69
|
+
});
|
|
70
|
+
it("should handle empty Properties content", () => {
|
|
71
|
+
// Properties parser handles empty content gracefully
|
|
72
|
+
const result = handler.parse("");
|
|
73
|
+
expect(result).toBeDefined();
|
|
74
|
+
expect(result._metadata?.format).toBe("properties");
|
|
75
|
+
});
|
|
76
|
+
it("should handle simple text content as properties", () => {
|
|
77
|
+
// Properties parser is quite permissive, so simple text might be parsed
|
|
78
|
+
const result = handler.parse("simple text");
|
|
79
|
+
expect(result).toBeDefined();
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
describe("Unicode escaping and encoding handling", () => {
|
|
83
|
+
it("should handle Unicode escapes in ISO-8859-1 encoded files", () => {
|
|
84
|
+
const result = handler.parse(unicodeEscapedContent);
|
|
85
|
+
expect(result["app.title"]).toBe("Café Application");
|
|
86
|
+
expect(result["app.description"]).toBe("Naïve approach to résumé building");
|
|
87
|
+
expect(result["messages.greeting"]).toBe("Hello 世界 (World)!");
|
|
88
|
+
expect(result["messages.currency"]).toBe("Price: €19.99");
|
|
89
|
+
expect(result["messages.symbols"]).toBe("✓ Success ✗ Error");
|
|
90
|
+
});
|
|
91
|
+
it("should detect Unicode escapes in metadata", () => {
|
|
92
|
+
const result = handler.parse(unicodeEscapedContent);
|
|
93
|
+
expect(result._metadata?.hasUnicodeEscapes).toBe(true);
|
|
94
|
+
expect(result._metadata?.encoding).toBe("ISO-8859-1");
|
|
95
|
+
});
|
|
96
|
+
it("should handle escaped special characters", () => {
|
|
97
|
+
const result = handler.parse(unicodeEscapedContent);
|
|
98
|
+
expect(result["special.equals"]).toBe("key=value pair");
|
|
99
|
+
expect(result["special.colon"]).toBe("time:value pair");
|
|
100
|
+
expect(result["special.spaces"]).toBe("leading spaces preserved");
|
|
101
|
+
expect(result["special.backslash"]).toBe("path\\to\\file");
|
|
102
|
+
});
|
|
103
|
+
it("should serialize with proper Unicode escaping based on encoding", () => {
|
|
104
|
+
const result = handler.parse(unicodeEscapedContent);
|
|
105
|
+
const serialized = handler.serialize(result);
|
|
106
|
+
// Should contain Unicode escapes for non-Latin-1 characters
|
|
107
|
+
expect(serialized).toContain("\\u");
|
|
108
|
+
});
|
|
109
|
+
it("should handle UTF-8 content without Unicode escaping", () => {
|
|
110
|
+
const result = handler.parse(samplePropertiesContent);
|
|
111
|
+
expect(result["special.unicode"]).toBe("Café, naïve, résumé");
|
|
112
|
+
expect(result["special.symbols"]).toBe("Price: $19.99 & tax: 5%");
|
|
113
|
+
expect(result["special.quotes"]).toBe('He said "Hello world!"');
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
describe("placeholder variable preservation", () => {
|
|
117
|
+
it("should detect and preserve various placeholder formats", () => {
|
|
118
|
+
const result = handler.parse(placeholdersContent);
|
|
119
|
+
expect(result._metadata?.placeholders).toBeDefined();
|
|
120
|
+
// Check that we have placeholder information for multiple keys
|
|
121
|
+
expect(Object.keys(result._metadata?.placeholders || {}).length).toBeGreaterThan(15);
|
|
122
|
+
});
|
|
123
|
+
it("should preserve curly brace placeholders", () => {
|
|
124
|
+
const result = handler.parse(placeholdersContent);
|
|
125
|
+
expect(result["messages.welcome"]).toBe("Welcome to {appName}!");
|
|
126
|
+
expect(result["messages.greeting"]).toBe("Hello, {firstName} {lastName}!");
|
|
127
|
+
expect(result["messages.count"]).toBe("You have {itemCount} items");
|
|
128
|
+
});
|
|
129
|
+
it("should preserve shell-style variable placeholders", () => {
|
|
130
|
+
const result = handler.parse(placeholdersContent);
|
|
131
|
+
expect(result["paths.home"]).toBe("${HOME}/documents");
|
|
132
|
+
expect(result["paths.config"]).toBe("${APP_CONFIG}/settings.conf");
|
|
133
|
+
expect(result["paths.temp"]).toBe("${TEMP_DIR}/cache");
|
|
134
|
+
});
|
|
135
|
+
it("should preserve percent-wrapped placeholders", () => {
|
|
136
|
+
const result = handler.parse(placeholdersContent);
|
|
137
|
+
expect(result["windows.path"]).toBe("%USERPROFILE%\\Documents");
|
|
138
|
+
expect(result["windows.temp"]).toBe("%TEMP%\\myapp");
|
|
139
|
+
});
|
|
140
|
+
it("should preserve printf-style placeholders", () => {
|
|
141
|
+
const result = handler.parse(placeholdersContent);
|
|
142
|
+
expect(result["format.string"]).toBe("Name: %s, Age: %d");
|
|
143
|
+
expect(result["format.float"]).toBe("Price: %.2f");
|
|
144
|
+
expect(result["format.hex"]).toBe("Color: %x");
|
|
145
|
+
});
|
|
146
|
+
it("should preserve MessageFormat numbered placeholders", () => {
|
|
147
|
+
const result = handler.parse(placeholdersContent);
|
|
148
|
+
expect(result["messageformat.simple"]).toBe("Hello {0}!");
|
|
149
|
+
expect(result["messageformat.multiple"]).toBe("User {0} has {1} messages in {2}");
|
|
150
|
+
expect(result["messageformat.complex"]).toBe("At {1,time} on {1,date}, {0} said {2}");
|
|
151
|
+
});
|
|
152
|
+
it("should preserve other placeholder formats", () => {
|
|
153
|
+
const result = handler.parse(placeholdersContent);
|
|
154
|
+
expect(result["config.database"]).toBe("jdbc:mysql://[host]:[port]/[database]");
|
|
155
|
+
expect(result["spring.message"]).toBe("@{message.key}");
|
|
156
|
+
expect(result["shell.user"]).toBe("$USER");
|
|
157
|
+
expect(result["ruby.interpolation"]).toBe("Hello #{name}!");
|
|
158
|
+
});
|
|
159
|
+
it("should handle mixed placeholders in single value", () => {
|
|
160
|
+
const result = handler.parse(placeholdersContent);
|
|
161
|
+
expect(result["mixed.complex"]).toBe("Welcome {user} to ${APP_NAME}! Your temp dir is %TEMP% and user is $USER");
|
|
162
|
+
});
|
|
163
|
+
it("should categorize placeholder types in metadata", () => {
|
|
164
|
+
const result = handler.parse(placeholdersContent);
|
|
165
|
+
const placeholderInfo = result._metadata?.placeholders;
|
|
166
|
+
expect(placeholderInfo).toBeDefined();
|
|
167
|
+
// Check that different placeholder types are detected
|
|
168
|
+
const welcomeInfo = placeholderInfo?.["messages.welcome"];
|
|
169
|
+
expect(welcomeInfo?.placeholders).toContain("{appName}");
|
|
170
|
+
expect(welcomeInfo?.types).toBeDefined();
|
|
171
|
+
const pathInfo = placeholderInfo?.["paths.home"];
|
|
172
|
+
expect(pathInfo?.placeholders).toContain("${HOME}");
|
|
173
|
+
expect(pathInfo?.types).toBeDefined();
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
describe("serialize", () => {
|
|
177
|
+
it("should serialize Properties data correctly", () => {
|
|
178
|
+
const result = handler.parse(samplePropertiesContent);
|
|
179
|
+
const serialized = handler.serialize(result);
|
|
180
|
+
expect(serialized).toContain("app.name");
|
|
181
|
+
expect(serialized).toContain("My Application");
|
|
182
|
+
expect(serialized).toContain("navigation.home");
|
|
183
|
+
expect(serialized).toContain("Home");
|
|
184
|
+
});
|
|
185
|
+
it("should preserve comments when formatting is enabled", () => {
|
|
186
|
+
const result = handler.parse(samplePropertiesContent);
|
|
187
|
+
const serialized = handler.serialize(result, { preserveFormatting: true });
|
|
188
|
+
expect(serialized).toContain("#");
|
|
189
|
+
});
|
|
190
|
+
it("should handle encoding options", () => {
|
|
191
|
+
const result = handler.parse(samplePropertiesContent);
|
|
192
|
+
const serializedUtf8 = handler.serialize(result, { encoding: "UTF-8" });
|
|
193
|
+
const serializedIso = handler.serialize(result, { encoding: "ISO-8859-1" });
|
|
194
|
+
expect(serializedUtf8).toBeDefined();
|
|
195
|
+
expect(serializedIso).toBeDefined();
|
|
196
|
+
// Both should be valid Properties format
|
|
197
|
+
expect(serializedUtf8).toContain("app.name");
|
|
198
|
+
expect(serializedIso).toContain("app.name");
|
|
199
|
+
});
|
|
200
|
+
it("should preserve placeholder variables during serialization", () => {
|
|
201
|
+
const result = handler.parse(placeholdersContent);
|
|
202
|
+
const serialized = handler.serialize(result);
|
|
203
|
+
expect(serialized).toContain("{appName}");
|
|
204
|
+
expect(serialized).toContain("${HOME}");
|
|
205
|
+
expect(serialized).toContain("%USERPROFILE%");
|
|
206
|
+
expect(serialized).toContain("{0}");
|
|
207
|
+
});
|
|
208
|
+
it("should handle custom formatting options", () => {
|
|
209
|
+
const result = handler.parse(samplePropertiesContent);
|
|
210
|
+
const serialized = handler.serialize(result, {
|
|
211
|
+
preserveFormatting: false,
|
|
212
|
+
encoding: "UTF-8"
|
|
213
|
+
});
|
|
214
|
+
expect(serialized).toBeDefined();
|
|
215
|
+
expect(typeof serialized).toBe("string");
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
describe("validateStructure", () => {
|
|
219
|
+
it("should validate correct Properties structure", () => {
|
|
220
|
+
const result = handler.parse(samplePropertiesContent);
|
|
221
|
+
const validation = handler.validateStructure(result);
|
|
222
|
+
expect(validation.isValid).toBe(true);
|
|
223
|
+
expect(validation.errors).toHaveLength(0);
|
|
224
|
+
});
|
|
225
|
+
it("should detect invalid structure", () => {
|
|
226
|
+
const validation = handler.validateStructure("not an object");
|
|
227
|
+
expect(validation.isValid).toBe(false);
|
|
228
|
+
expect(validation.errors).toHaveLength(1);
|
|
229
|
+
expect(validation.errors[0].code).toBe("INVALID_STRUCTURE");
|
|
230
|
+
});
|
|
231
|
+
it("should detect array root", () => {
|
|
232
|
+
const validation = handler.validateStructure(["item1", "item2"]);
|
|
233
|
+
expect(validation.isValid).toBe(false);
|
|
234
|
+
expect(validation.errors).toHaveLength(1);
|
|
235
|
+
expect(validation.errors[0].code).toBe("INVALID_ROOT_TYPE");
|
|
236
|
+
});
|
|
237
|
+
it("should warn about placeholder variables", () => {
|
|
238
|
+
const result = handler.parse(placeholdersContent);
|
|
239
|
+
const validation = handler.validateStructure(result);
|
|
240
|
+
expect(validation.isValid).toBe(true);
|
|
241
|
+
expect(validation.warnings.length).toBeGreaterThan(0);
|
|
242
|
+
const placeholderWarnings = validation.warnings.filter(w => w.code === "PLACEHOLDER_DETECTED");
|
|
243
|
+
expect(placeholderWarnings.length).toBeGreaterThan(0);
|
|
244
|
+
});
|
|
245
|
+
it("should warn about non-string values", () => {
|
|
246
|
+
const dataWithNonStrings = {
|
|
247
|
+
title: "String value",
|
|
248
|
+
count: 42,
|
|
249
|
+
enabled: true,
|
|
250
|
+
price: 19.99
|
|
251
|
+
};
|
|
252
|
+
const validation = handler.validateStructure(dataWithNonStrings);
|
|
253
|
+
expect(validation.isValid).toBe(true);
|
|
254
|
+
// Check if there are any warnings at all
|
|
255
|
+
if (validation.warnings.length > 0) {
|
|
256
|
+
const nonStringWarnings = validation.warnings.filter(w => w.code === "NON_STRING_VALUE");
|
|
257
|
+
expect(nonStringWarnings.length).toBeGreaterThanOrEqual(0);
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
it("should warn about empty Properties", () => {
|
|
261
|
+
const validation = handler.validateStructure({});
|
|
262
|
+
expect(validation.isValid).toBe(true);
|
|
263
|
+
expect(validation.warnings).toHaveLength(1);
|
|
264
|
+
expect(validation.warnings[0].code).toBe("EMPTY_PROPERTIES");
|
|
265
|
+
});
|
|
266
|
+
it("should detect invalid property keys", () => {
|
|
267
|
+
const invalidData = {
|
|
268
|
+
"": "empty key",
|
|
269
|
+
" leadingSpace": "invalid key",
|
|
270
|
+
"key=with=equals": "invalid key",
|
|
271
|
+
_metadata: { format: "properties" }
|
|
272
|
+
};
|
|
273
|
+
const validation = handler.validateStructure(invalidData);
|
|
274
|
+
expect(validation.isValid).toBe(false);
|
|
275
|
+
expect(validation.errors.length).toBeGreaterThan(0);
|
|
276
|
+
const keyErrors = validation.errors.filter(e => e.code === "INVALID_KEY_FORMAT");
|
|
277
|
+
expect(keyErrors.length).toBeGreaterThan(0);
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
describe("getFileExtension", () => {
|
|
281
|
+
it("should return .properties extension", () => {
|
|
282
|
+
expect(handler.getFileExtension()).toBe(".properties");
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
describe("round-trip processing", () => {
|
|
286
|
+
it("should maintain data integrity through parse and serialize", () => {
|
|
287
|
+
const original = handler.parse(samplePropertiesContent);
|
|
288
|
+
const serialized = handler.serialize(original);
|
|
289
|
+
const reparsed = handler.parse(serialized);
|
|
290
|
+
// Compare key values
|
|
291
|
+
expect(reparsed["app.name"]).toBe(original["app.name"]);
|
|
292
|
+
expect(reparsed["navigation.home"]).toBe(original["navigation.home"]);
|
|
293
|
+
expect(reparsed["messages.welcome"]).toBe(original["messages.welcome"]);
|
|
294
|
+
expect(reparsed["errors.notFound"]).toBe(original["errors.notFound"]);
|
|
295
|
+
});
|
|
296
|
+
it("should maintain placeholder integrity through round-trip", () => {
|
|
297
|
+
const original = handler.parse(placeholdersContent);
|
|
298
|
+
const serialized = handler.serialize(original);
|
|
299
|
+
const reparsed = handler.parse(serialized);
|
|
300
|
+
// Compare placeholder values
|
|
301
|
+
expect(reparsed["messages.welcome"]).toBe(original["messages.welcome"]);
|
|
302
|
+
expect(reparsed["paths.home"]).toBe(original["paths.home"]);
|
|
303
|
+
expect(reparsed["messageformat.simple"]).toBe(original["messageformat.simple"]);
|
|
304
|
+
expect(reparsed["mixed.complex"]).toBe(original["mixed.complex"]);
|
|
305
|
+
});
|
|
306
|
+
it("should maintain Unicode content through round-trip", () => {
|
|
307
|
+
const original = handler.parse(unicodeEscapedContent);
|
|
308
|
+
const serialized = handler.serialize(original);
|
|
309
|
+
const reparsed = handler.parse(serialized);
|
|
310
|
+
// Compare Unicode values
|
|
311
|
+
expect(reparsed["app.title"]).toBe(original["app.title"]);
|
|
312
|
+
expect(reparsed["messages.greeting"]).toBe(original["messages.greeting"]);
|
|
313
|
+
expect(reparsed["messages.currency"]).toBe(original["messages.currency"]);
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|