@karpeleslab/klbfw 0.1.12 → 0.2.0

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.
Files changed (46) hide show
  1. package/CLAUDE.md +50 -0
  2. package/README.md +199 -35
  3. package/cookies.js +107 -41
  4. package/coverage/clover.xml +835 -0
  5. package/coverage/coverage-final.json +9 -0
  6. package/coverage/lcov-report/base.css +224 -0
  7. package/coverage/lcov-report/block-navigation.js +87 -0
  8. package/coverage/lcov-report/cookies.js.html +334 -0
  9. package/coverage/lcov-report/favicon.png +0 -0
  10. package/coverage/lcov-report/fw-wrapper.js.html +163 -0
  11. package/coverage/lcov-report/index.html +131 -0
  12. package/coverage/lcov-report/index.js.html +196 -0
  13. package/coverage/lcov-report/internal.js.html +604 -0
  14. package/coverage/lcov-report/klbfw/cookies.js.html +490 -0
  15. package/coverage/lcov-report/klbfw/fw-wrapper.js.html +745 -0
  16. package/coverage/lcov-report/klbfw/index.html +206 -0
  17. package/coverage/lcov-report/klbfw/index.js.html +235 -0
  18. package/coverage/lcov-report/klbfw/internal.js.html +811 -0
  19. package/coverage/lcov-report/klbfw/rest.js.html +565 -0
  20. package/coverage/lcov-report/klbfw/test/index.html +116 -0
  21. package/coverage/lcov-report/klbfw/test/setup.js.html +1105 -0
  22. package/coverage/lcov-report/klbfw/upload.js.html +3487 -0
  23. package/coverage/lcov-report/klbfw/util.js.html +388 -0
  24. package/coverage/lcov-report/prettify.css +1 -0
  25. package/coverage/lcov-report/prettify.js +2 -0
  26. package/coverage/lcov-report/rest.js.html +472 -0
  27. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  28. package/coverage/lcov-report/sorter.js +196 -0
  29. package/coverage/lcov-report/upload.js.html +1789 -0
  30. package/coverage/lcov-report/util.js.html +313 -0
  31. package/coverage/lcov.info +1617 -0
  32. package/fw-wrapper.js +221 -26
  33. package/index.js +16 -2
  34. package/internal.js +186 -102
  35. package/package.json +21 -3
  36. package/rest.js +129 -81
  37. package/test/README.md +62 -0
  38. package/test/api.test.js +102 -0
  39. package/test/cookies.test.js +65 -0
  40. package/test/integration.test.js +481 -0
  41. package/test/rest.test.js +93 -0
  42. package/test/setup.js +341 -0
  43. package/test/upload.test.js +689 -0
  44. package/test/util.test.js +46 -0
  45. package/upload.js +1012 -442
  46. package/util.js +59 -21
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+
3
+ const util = require('../util');
4
+ const { setupSSRMode, setupClientMode, resetMocks } = require('./setup');
5
+
6
+ describe('Utility Module', () => {
7
+ beforeEach(() => {
8
+ resetMocks();
9
+
10
+ // Mock fetch response for i18n calls
11
+ global.fetch = jest.fn().mockImplementation(() => {
12
+ return Promise.resolve({
13
+ ok: true,
14
+ status: 200,
15
+ json: jest.fn().mockResolvedValue({
16
+ "hello": "Hello",
17
+ "goodbye": "Goodbye"
18
+ })
19
+ });
20
+ });
21
+ });
22
+
23
+ describe('getI18N', () => {
24
+ test('fetches locale data with specified language', async () => {
25
+ const i18n = await util.getI18N('en-US');
26
+ expect(fetch).toHaveBeenCalledWith('/_special/locale/en-US.json');
27
+ expect(i18n).toHaveProperty('hello', 'Hello');
28
+ });
29
+
30
+ test('uses FW.Locale if no language specified', async () => {
31
+ // FW.Locale is set to en-US in setup
32
+ const i18n = await util.getI18N();
33
+ expect(fetch).toHaveBeenCalledWith('/_special/locale/en-US.json');
34
+ expect(i18n).toHaveProperty('hello', 'Hello');
35
+ });
36
+ });
37
+
38
+ describe('Utility Functions', () => {
39
+ test('trimPrefix processes URL correctly', () => {
40
+ const result = util.trimPrefix('/l/en-US/path');
41
+ expect(result).toHaveLength(2);
42
+ expect(result[0]).toHaveProperty('l', 'en-US');
43
+ expect(result[1]).toBe('/path');
44
+ });
45
+ });
46
+ });