Skip to content

Commit 7b5de9b

Browse files
committed
Fixes $json store.
1 parent beb3a32 commit 7b5de9b

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

Diff for: src/stores/dictionary.ts

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export function getMessageFromDictionary(locale: string, id: string) {
3434
}
3535
tmpDict = tmpDict[ids[i]];
3636
}
37+
return tmpDict;
3738
}
3839
return null
3940
}

Diff for: tests/index.test.js

+26
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,32 @@ describe("json", function() {
268268
});
269269
unsubscribe()
270270
});
271+
272+
it('retrieves json segment of messages that are nested', () => {
273+
addMessages("en-US", {
274+
nested: {
275+
deep: {
276+
deeper: 42
277+
}
278+
},
279+
});
280+
281+
const unsubscribe = json.subscribe(j => {
282+
expect(j("nested.deep.deeper")).toStrictEqual(42);
283+
});
284+
unsubscribe();
285+
});
286+
287+
it('retrieves json data of any type', () => {
288+
addMessages("en-US", {
289+
arr: [42]
290+
});
291+
292+
const unsubscribe = json.subscribe(j => {
293+
expect(j("arr")).toStrictEqual([42]);
294+
});
295+
unsubscribe();
296+
});
271297
});
272298

273299
describe("time", function() {

0 commit comments

Comments
 (0)