@karpeleslab/klbfw 0.1.13 → 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.
- package/CLAUDE.md +50 -0
- package/README.md +199 -35
- package/cookies.js +107 -41
- package/coverage/clover.xml +835 -0
- package/coverage/coverage-final.json +9 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/cookies.js.html +334 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/fw-wrapper.js.html +163 -0
- package/coverage/lcov-report/index.html +131 -0
- package/coverage/lcov-report/index.js.html +196 -0
- package/coverage/lcov-report/internal.js.html +604 -0
- package/coverage/lcov-report/klbfw/cookies.js.html +490 -0
- package/coverage/lcov-report/klbfw/fw-wrapper.js.html +745 -0
- package/coverage/lcov-report/klbfw/index.html +206 -0
- package/coverage/lcov-report/klbfw/index.js.html +235 -0
- package/coverage/lcov-report/klbfw/internal.js.html +811 -0
- package/coverage/lcov-report/klbfw/rest.js.html +565 -0
- package/coverage/lcov-report/klbfw/test/index.html +116 -0
- package/coverage/lcov-report/klbfw/test/setup.js.html +1105 -0
- package/coverage/lcov-report/klbfw/upload.js.html +3487 -0
- package/coverage/lcov-report/klbfw/util.js.html +388 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/rest.js.html +472 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/upload.js.html +1789 -0
- package/coverage/lcov-report/util.js.html +313 -0
- package/coverage/lcov.info +1617 -0
- package/fw-wrapper.js +221 -26
- package/index.js +16 -2
- package/internal.js +186 -102
- package/package.json +21 -3
- package/rest.js +129 -81
- package/test/README.md +62 -0
- package/test/api.test.js +102 -0
- package/test/cookies.test.js +65 -0
- package/test/integration.test.js +481 -0
- package/test/rest.test.js +93 -0
- package/test/setup.js +341 -0
- package/test/upload.test.js +689 -0
- package/test/util.test.js +46 -0
- package/upload.js +987 -421
- 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
|
+
});
|