@lynx-js/lynx-ui-common 3.135.4 → 3.136.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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @lynx-js/lynx-ui-common
2
2
 
3
+ ## 3.136.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Exclude test modules from compiled package output. ([#255](https://github.com/lynx-family/lynx-ui/pull/255))
8
+
3
9
  ## 3.135.4
4
10
 
5
11
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/lynx-ui-common",
3
- "version": "3.135.4",
3
+ "version": "3.136.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/lynx-family/lynx-ui.git",
@@ -2,7 +2,8 @@
2
2
  // Licensed under the Apache License Version 2.0 that can be found in the
3
3
  // LICENSE file in the root directory of this source tree.
4
4
 
5
- import { describe, it, expect } from 'vitest'
5
+ import { describe, expect, it } from 'vitest'
6
+
6
7
  import { get, noop } from './common'
7
8
 
8
9
  describe('common utils', () => {
@@ -2,17 +2,18 @@
2
2
  // Licensed under the Apache License Version 2.0 that can be found in the
3
3
  // LICENSE file in the root directory of this source tree.
4
4
 
5
- import { describe, it, expect, vi, beforeEach } from 'vitest'
5
+ import { beforeEach, describe, expect, it, vi } from 'vitest'
6
+
6
7
  import {
7
8
  InvokeRejectError,
8
- setNativePropsByRef,
9
- setNativePropsById,
10
- setNativeProps,
11
- invokeByRef,
12
- invokeById,
13
- getRectByRef,
14
- getRectById,
15
9
  getRect,
10
+ getRectById,
11
+ getRectByRef,
12
+ invokeById,
13
+ invokeByRef,
14
+ setNativeProps,
15
+ setNativePropsById,
16
+ setNativePropsByRef,
16
17
  } from './selector'
17
18
 
18
19
  // Mock the global lynx object
@@ -2,7 +2,8 @@
2
2
  // Licensed under the Apache License Version 2.0 that can be found in the
3
3
  // LICENSE file in the root directory of this source tree.
4
4
 
5
- import { describe, it, expect, beforeEach } from 'vitest'
5
+ import { beforeEach, describe, expect, it } from 'vitest'
6
+
6
7
  import {
7
8
  lynxSDKVersionStringToNumber,
8
9
  nativeLynxSDKVersionGreaterThan,
package/tsconfig.json CHANGED
@@ -8,5 +8,7 @@
8
8
  ],
9
9
  "exclude": [
10
10
  "**/*.test.ts",
11
+ "**/*.test.tsx",
12
+ "**/__tests__/**",
11
13
  ],
12
14
  }
@@ -1,55 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import { get, noop } from "./common.jsx";
3
- describe('common utils', ()=>{
4
- describe('get', ()=>{
5
- const testObj = {
6
- a: {
7
- b: {
8
- c: 'value'
9
- },
10
- arr: [
11
- {
12
- nested: 'array-value'
13
- }
14
- ]
15
- },
16
- nullValue: null,
17
- undefinedValue: void 0
18
- };
19
- it('should return value for dot notation path', ()=>{
20
- expect(get(testObj, 'a.b.c')).toBe('value');
21
- });
22
- it('should return value for bracket notation path', ()=>{
23
- expect(get(testObj, 'a[b][c]')).toBe('value');
24
- });
25
- it('should return value for array index path', ()=>{
26
- expect(get(testObj, 'a.arr[0].nested')).toBe('array-value');
27
- expect(get(testObj, 'a.arr.0.nested')).toBe('array-value');
28
- });
29
- it('should return default value when path does not exist', ()=>{
30
- expect(get(testObj, 'a.b.d', 'default')).toBe('default');
31
- expect(get(testObj, 'x.y.z', 'default')).toBe('default');
32
- });
33
- it('should return undefined when no default value is provided and path does not exist', ()=>{
34
- expect(get(testObj, 'a.b.d')).toBeUndefined();
35
- });
36
- it('should handle null and undefined values', ()=>{
37
- expect(get(testObj, 'nullValue.something', 'default')).toBe('default');
38
- expect(get(testObj, 'undefinedValue.something', 'default')).toBe('default');
39
- });
40
- it('should return default value when input is not an object', ()=>{
41
- expect(get(null, 'any.path', 'default')).toBe('default');
42
- expect(get(void 0, 'any.path', 'default')).toBe('default');
43
- expect(get('string', 'any.path', 'default')).toBe('default');
44
- expect(get(123, 'any.path', 'default')).toBe('default');
45
- });
46
- });
47
- describe('noop', ()=>{
48
- it('should be a function that returns undefined', ()=>{
49
- expect(typeof noop).toBe('function');
50
- expect(noop()).toBeUndefined();
51
- });
52
- });
53
- });
54
-
55
- //# sourceMappingURL=common.test.jsx.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils/common.test.jsx","sources":["../../src/utils/common.test.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { describe, it, expect } from 'vitest'\nimport { get, noop } from './common'\n\ndescribe('common utils', () => {\n describe('get', () => {\n const testObj = {\n a: {\n b: {\n c: 'value',\n },\n arr: [{ nested: 'array-value' }],\n },\n nullValue: null,\n undefinedValue: undefined,\n }\n\n it('should return value for dot notation path', () => {\n expect(get(testObj, 'a.b.c')).toBe('value')\n })\n\n it('should return value for bracket notation path', () => {\n expect(get(testObj, 'a[b][c]')).toBe('value')\n })\n\n it('should return value for array index path', () => {\n expect(get(testObj, 'a.arr[0].nested')).toBe('array-value')\n expect(get(testObj, 'a.arr.0.nested')).toBe('array-value')\n })\n\n it('should return default value when path does not exist', () => {\n expect(get(testObj, 'a.b.d', 'default')).toBe('default')\n expect(get(testObj, 'x.y.z', 'default')).toBe('default')\n })\n\n it('should return undefined when no default value is provided and path does not exist', () => {\n expect(get(testObj, 'a.b.d')).toBeUndefined()\n })\n\n it('should handle null and undefined values', () => {\n expect(get(testObj, 'nullValue.something', 'default')).toBe('default')\n expect(get(testObj, 'undefinedValue.something', 'default')).toBe(\n 'default',\n )\n })\n\n it('should return default value when input is not an object', () => {\n expect(get(null, 'any.path', 'default')).toBe('default')\n expect(get(undefined, 'any.path', 'default')).toBe('default')\n expect(get('string', 'any.path', 'default')).toBe('default')\n expect(get(123, 'any.path', 'default')).toBe('default')\n })\n })\n\n describe('noop', () => {\n it('should be a function that returns undefined', () => {\n expect(typeof noop).toBe('function')\n expect(noop()).toBeUndefined()\n })\n })\n})\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+0,0 @@
1
- import { beforeEach, describe, expect, it, vi } from "vitest";
2
- import { InvokeRejectError, getRect, getRectById, getRectByRef, invokeById, invokeByRef, setNativeProps, setNativePropsById, setNativePropsByRef } from "./selector.jsx";
3
- const mockExec = vi.fn();
4
- const mockSelect = vi.fn().mockReturnThis();
5
- const mockSetNativeProps = vi.fn().mockReturnThis();
6
- const mockInvoke = vi.fn().mockReturnThis();
7
- global.lynx = {
8
- createSelectorQuery: ()=>({
9
- select: mockSelect,
10
- setNativeProps: mockSetNativeProps,
11
- invoke: mockInvoke,
12
- exec: mockExec
13
- })
14
- };
15
- describe('selector utils', ()=>{
16
- beforeEach(()=>{
17
- vi.clearAllMocks();
18
- });
19
- describe('InvokeRejectError', ()=>{
20
- it('should create error with code and message', ()=>{
21
- const error = new InvokeRejectError(404, 'Not Found');
22
- expect(error.errorCode).toBe(404);
23
- expect(error.message).toBe('Not Found');
24
- });
25
- });
26
- describe('setNativeProps functions', ()=>{
27
- const testProps = {
28
- style: {
29
- color: 'red'
30
- }
31
- };
32
- describe('setNativePropsByRef', ()=>{
33
- it('should call setNativeProps with ref', ()=>{
34
- const mockRef = {
35
- current: {
36
- setNativeProps: vi.fn().mockReturnThis(),
37
- exec: vi.fn()
38
- }
39
- };
40
- setNativePropsByRef(mockRef, testProps);
41
- expect(mockRef.current.setNativeProps).toHaveBeenCalledWith(testProps);
42
- expect(mockRef.current.exec).toHaveBeenCalled();
43
- });
44
- });
45
- describe('setNativePropsById', ()=>{
46
- it('should call setNativeProps with id', ()=>{
47
- setNativePropsById('test-id', testProps);
48
- expect(mockSelect).toHaveBeenCalledWith('#test-id');
49
- expect(mockSetNativeProps).toHaveBeenCalledWith(testProps);
50
- expect(mockExec).toHaveBeenCalled();
51
- });
52
- });
53
- describe('setNativeProps', ()=>{
54
- it('should use id when available', ()=>{
55
- setNativeProps({
56
- id: 'test-id'
57
- }, testProps);
58
- expect(mockSelect).toHaveBeenCalledWith('#test-id');
59
- });
60
- it('should use ref when id is not available', ()=>{
61
- const mockRef = {
62
- current: {
63
- setNativeProps: vi.fn().mockReturnThis(),
64
- exec: vi.fn()
65
- }
66
- };
67
- setNativeProps({
68
- ref: mockRef
69
- }, testProps);
70
- expect(mockRef.current.setNativeProps).toHaveBeenCalledWith(testProps);
71
- });
72
- });
73
- });
74
- describe('invoke functions', ()=>{
75
- const method = 'testMethod';
76
- const params = {
77
- test: true
78
- };
79
- describe('invokeByRef', ()=>{
80
- it('should resolve successfully', async ()=>{
81
- const successResponse = {
82
- data: 'success'
83
- };
84
- const mockRef = {
85
- current: {
86
- invoke: vi.fn().mockImplementation(({ success })=>({
87
- exec: ()=>success(successResponse)
88
- }))
89
- }
90
- };
91
- const result = await invokeByRef(mockRef, method, params);
92
- expect(result).toBe(successResponse);
93
- });
94
- it('should reject when no ref current', async ()=>{
95
- await expect(invokeByRef({}, method, params)).rejects.toThrow('no node found for the ref');
96
- });
97
- it('should reject on failure', async ()=>{
98
- const mockRef = {
99
- current: {
100
- invoke: vi.fn().mockImplementation(({ fail })=>({
101
- exec: ()=>fail({
102
- code: 500,
103
- data: 'error'
104
- })
105
- }))
106
- }
107
- };
108
- await expect(invokeByRef(mockRef, method, params)).rejects.toThrow();
109
- });
110
- });
111
- describe('invokeById', ()=>{
112
- it('should resolve successfully', async ()=>{
113
- const successResponse = {
114
- data: 'success'
115
- };
116
- mockInvoke.mockImplementation(({ success })=>{
117
- success(successResponse);
118
- return {
119
- exec: mockExec
120
- };
121
- });
122
- const result = await invokeById('test-id', method, params);
123
- expect(result).toBe(successResponse);
124
- });
125
- it('should reject on failure', async ()=>{
126
- mockInvoke.mockImplementation(({ fail })=>{
127
- fail({
128
- code: 500,
129
- data: 'error'
130
- });
131
- return {
132
- exec: mockExec
133
- };
134
- });
135
- await expect(invokeById('test-id', method, params)).rejects.toThrow();
136
- });
137
- });
138
- });
139
- describe('getRect functions', ()=>{
140
- const mockRect = {
141
- left: 0,
142
- top: 0,
143
- width: 100,
144
- height: 100
145
- };
146
- describe('getRectByRef', ()=>{
147
- it('should get rect relative to viewport', async ()=>{
148
- const mockRef = {
149
- current: {
150
- invoke: vi.fn().mockImplementation(({ success })=>({
151
- exec: ()=>success(mockRect)
152
- }))
153
- }
154
- };
155
- const result = await getRectByRef(mockRef);
156
- expect(result).toEqual(mockRect);
157
- });
158
- it('should get rect relative to screen', async ()=>{
159
- const mockRef = {
160
- current: {
161
- invoke: vi.fn().mockImplementation(({ success, params })=>({
162
- exec: ()=>{
163
- expect(params.relativeTo).toBe('screen');
164
- success(mockRect);
165
- }
166
- }))
167
- }
168
- };
169
- const result = await getRectByRef(mockRef, true);
170
- expect(result).toEqual(mockRect);
171
- });
172
- });
173
- describe('getRectById', ()=>{
174
- it('should get rect by id', async ()=>{
175
- mockInvoke.mockImplementation(({ success })=>{
176
- success(mockRect);
177
- return {
178
- exec: mockExec
179
- };
180
- });
181
- const result = await getRectById('test-id');
182
- expect(result).toEqual(mockRect);
183
- });
184
- });
185
- describe('getRect', ()=>{
186
- it('should use id when available', async ()=>{
187
- mockInvoke.mockImplementation(({ success })=>{
188
- success(mockRect);
189
- return {
190
- exec: mockExec
191
- };
192
- });
193
- const result = await getRect({
194
- id: 'test-id'
195
- });
196
- expect(result).toEqual(mockRect);
197
- });
198
- it('should use ref when id is not available', async ()=>{
199
- const mockRef = {
200
- current: {
201
- invoke: vi.fn().mockImplementation(({ success })=>({
202
- exec: ()=>success(mockRect)
203
- }))
204
- }
205
- };
206
- const result = await getRect({
207
- ref: mockRef
208
- });
209
- expect(result).toEqual(mockRect);
210
- });
211
- });
212
- });
213
- });
214
-
215
- //# sourceMappingURL=selector.test.jsx.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils/selector.test.jsx","sources":["../../src/utils/selector.test.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { describe, it, expect, vi, beforeEach } from 'vitest'\nimport {\n InvokeRejectError,\n setNativePropsByRef,\n setNativePropsById,\n setNativeProps,\n invokeByRef,\n invokeById,\n getRectByRef,\n getRectById,\n getRect,\n} from './selector'\n\n// Mock the global lynx object\nconst mockExec = vi.fn()\nconst mockSelect = vi.fn().mockReturnThis()\nconst mockSetNativeProps = vi.fn().mockReturnThis()\nconst mockInvoke = vi.fn().mockReturnThis()\n\nglobal.lynx = {\n // @ts-expect-error expected\n createSelectorQuery: () => ({\n select: mockSelect,\n setNativeProps: mockSetNativeProps,\n invoke: mockInvoke,\n exec: mockExec,\n }),\n}\n\ndescribe('selector utils', () => {\n beforeEach(() => {\n vi.clearAllMocks()\n })\n\n describe('InvokeRejectError', () => {\n it('should create error with code and message', () => {\n const error = new InvokeRejectError(404, 'Not Found')\n expect(error.errorCode).toBe(404)\n expect(error.message).toBe('Not Found')\n })\n })\n\n describe('setNativeProps functions', () => {\n const testProps = { style: { color: 'red' } }\n\n describe('setNativePropsByRef', () => {\n it('should call setNativeProps with ref', () => {\n const mockRef = {\n current: {\n setNativeProps: vi.fn().mockReturnThis(),\n exec: vi.fn(),\n },\n }\n // @ts-expect-error expected\n setNativePropsByRef(mockRef, testProps)\n expect(mockRef.current.setNativeProps).toHaveBeenCalledWith(testProps)\n expect(mockRef.current.exec).toHaveBeenCalled()\n })\n })\n\n describe('setNativePropsById', () => {\n it('should call setNativeProps with id', () => {\n setNativePropsById('test-id', testProps)\n expect(mockSelect).toHaveBeenCalledWith('#test-id')\n expect(mockSetNativeProps).toHaveBeenCalledWith(testProps)\n expect(mockExec).toHaveBeenCalled()\n })\n })\n\n describe('setNativeProps', () => {\n it('should use id when available', () => {\n setNativeProps({ id: 'test-id' }, testProps)\n expect(mockSelect).toHaveBeenCalledWith('#test-id')\n })\n\n it('should use ref when id is not available', () => {\n const mockRef = {\n current: {\n setNativeProps: vi.fn().mockReturnThis(),\n exec: vi.fn(),\n },\n }\n // @ts-expect-error expected\n setNativeProps({ ref: mockRef }, testProps)\n expect(mockRef.current.setNativeProps).toHaveBeenCalledWith(testProps)\n })\n })\n })\n\n describe('invoke functions', () => {\n const method = 'testMethod'\n const params = { test: true }\n\n describe('invokeByRef', () => {\n it('should resolve successfully', async () => {\n const successResponse = { data: 'success' }\n const mockRef = {\n current: {\n invoke: vi.fn().mockImplementation(({ success }) => ({\n exec: () => success(successResponse),\n })),\n },\n }\n\n // @ts-expect-error expected\n const result = await invokeByRef(mockRef, method, params)\n expect(result).toBe(successResponse)\n })\n\n it('should reject when no ref current', async () => {\n // @ts-expect-error expected\n await expect(invokeByRef({}, method, params)).rejects.toThrow(\n 'no node found for the ref',\n )\n })\n\n it('should reject on failure', async () => {\n const mockRef = {\n current: {\n invoke: vi.fn().mockImplementation(({ fail }) => ({\n exec: () => fail({ code: 500, data: 'error' }),\n })),\n },\n }\n\n // @ts-expect-error expected\n await expect(invokeByRef(mockRef, method, params)).rejects.toThrow()\n })\n })\n\n describe('invokeById', () => {\n it('should resolve successfully', async () => {\n const successResponse = { data: 'success' }\n mockInvoke.mockImplementation(({ success }) => {\n success(successResponse)\n return { exec: mockExec }\n })\n\n const result = await invokeById('test-id', method, params)\n expect(result).toBe(successResponse)\n })\n\n it('should reject on failure', async () => {\n mockInvoke.mockImplementation(({ fail }) => {\n fail({ code: 500, data: 'error' })\n return { exec: mockExec }\n })\n\n await expect(invokeById('test-id', method, params)).rejects.toThrow()\n })\n })\n })\n\n describe('getRect functions', () => {\n const mockRect = {\n left: 0,\n top: 0,\n width: 100,\n height: 100,\n }\n\n describe('getRectByRef', () => {\n it('should get rect relative to viewport', async () => {\n const mockRef = {\n current: {\n invoke: vi.fn().mockImplementation(({ success }) => ({\n exec: () => success(mockRect),\n })),\n },\n }\n\n // @ts-expect-error expected\n const result = await getRectByRef(mockRef)\n expect(result).toEqual(mockRect)\n })\n\n it('should get rect relative to screen', async () => {\n const mockRef = {\n current: {\n invoke: vi.fn().mockImplementation(({ success, params }) => ({\n exec: () => {\n expect(params.relativeTo).toBe('screen')\n success(mockRect)\n },\n })),\n },\n }\n\n // @ts-expect-error expected\n const result = await getRectByRef(mockRef, true)\n expect(result).toEqual(mockRect)\n })\n })\n\n describe('getRectById', () => {\n it('should get rect by id', async () => {\n mockInvoke.mockImplementation(({ success }) => {\n success(mockRect)\n return { exec: mockExec }\n })\n\n const result = await getRectById('test-id')\n expect(result).toEqual(mockRect)\n })\n })\n\n describe('getRect', () => {\n it('should use id when available', async () => {\n mockInvoke.mockImplementation(({ success }) => {\n success(mockRect)\n return { exec: mockExec }\n })\n\n const result = await getRect({ id: 'test-id' })\n expect(result).toEqual(mockRect)\n })\n\n it('should use ref when id is not available', async () => {\n const mockRef = {\n current: {\n invoke: vi.fn().mockImplementation(({ success }) => ({\n exec: () => success(mockRect),\n })),\n },\n }\n\n // @ts-expect-error expected\n const result = await getRect({ ref: mockRef })\n expect(result).toEqual(mockRect)\n })\n })\n })\n})\n"],"names":["mockExec","vi","mockSelect","mockSetNativeProps","mockInvoke","global","describe","beforeEach","it","error","InvokeRejectError","expect","testProps","mockRef","setNativePropsByRef","setNativePropsById","setNativeProps","method","params","successResponse","success","result","invokeByRef","fail","invokeById","mockRect","getRectByRef","getRectById","getRect"],"mappings":";;AAkBA,MAAMA,WAAWC,GAAG,EAAE;AACtB,MAAMC,aAAaD,GAAG,EAAE,GAAG,cAAc;AACzC,MAAME,qBAAqBF,GAAG,EAAE,GAAG,cAAc;AACjD,MAAMG,aAAaH,GAAG,EAAE,GAAG,cAAc;AAEzCI,OAAO,IAAI,GAAG;IAEZ,qBAAqB,IAAO;YAC1B,QAAQH;YACR,gBAAgBC;YAChB,QAAQC;YACR,MAAMJ;QACR;AACF;AAEAM,SAAS,kBAAkB;IACzBC,WAAW;QACTN,GAAG,aAAa;IAClB;IAEAK,SAAS,qBAAqB;QAC5BE,GAAG,6CAA6C;YAC9C,MAAMC,QAAQ,IAAIC,kBAAkB,KAAK;YACzCC,OAAOF,MAAM,SAAS,EAAE,IAAI,CAAC;YAC7BE,OAAOF,MAAM,OAAO,EAAE,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CACnD,MAAM,IAAMA,QAAQK;4BACtB;oBACF;gBACF;gBAGA,MAAMJ,SAAS,MAAMO,QAAQ;oBAAE,KAAKf;gBAAQ;gBAC5CF,OAAOU,QAAQ,OAAO,CAACI;YACzB;QACF;IACF;AACF"}
@@ -1,77 +0,0 @@
1
- import { beforeEach, describe, expect, it } from "vitest";
2
- import { lynxSDKVersionStringToNumber, nativeLynxSDKVersionGreaterThan, nativeLynxSDKVersionLessThan } from "./version.jsx";
3
- function createMockSystemInfo(lynxSdkVersion) {
4
- return {
5
- lynxSdkVersion,
6
- osVersion: '1.0',
7
- pixelHeight: 100,
8
- pixelWidth: 100,
9
- pixelRatio: 1,
10
- platform: 'Android',
11
- runtimeType: 'quickjs'
12
- };
13
- }
14
- describe('version utils', ()=>{
15
- describe('lynxSDKVersionStringToNumber', ()=>{
16
- it('should convert version string to number correctly', ()=>{
17
- expect(lynxSDKVersionStringToNumber('1.2.3')).toBe(10203);
18
- expect(lynxSDKVersionStringToNumber('2.0.0')).toBe(20000);
19
- expect(lynxSDKVersionStringToNumber('0.1.0')).toBe(100);
20
- });
21
- it('should handle missing version parts', ()=>{
22
- expect(lynxSDKVersionStringToNumber('1')).toBe(10000);
23
- expect(lynxSDKVersionStringToNumber('1.2')).toBe(10200);
24
- expect(lynxSDKVersionStringToNumber('')).toBe(0);
25
- });
26
- it('should handle version strings with leading zeros', ()=>{
27
- expect(lynxSDKVersionStringToNumber('01.02.03')).toBe(10203);
28
- });
29
- it('should handle large version numbers', ()=>{
30
- expect(lynxSDKVersionStringToNumber('99.99.99')).toBe(999999);
31
- });
32
- });
33
- describe('nativeLynxSDKVersionGreaterThan', ()=>{
34
- beforeEach(()=>{
35
- global.SystemInfo = createMockSystemInfo('1.2.3');
36
- });
37
- it('should return true when native version is greater', ()=>{
38
- global.SystemInfo = createMockSystemInfo('1.2.4');
39
- expect(nativeLynxSDKVersionGreaterThan('1.2.3')).toBe(true);
40
- });
41
- it('should return false when native version is equal', ()=>{
42
- global.SystemInfo = createMockSystemInfo('1.2.3');
43
- expect(nativeLynxSDKVersionGreaterThan('1.2.3')).toBe(false);
44
- });
45
- it('should return false when native version is less', ()=>{
46
- global.SystemInfo = createMockSystemInfo('1.2.2');
47
- expect(nativeLynxSDKVersionGreaterThan('1.2.3')).toBe(false);
48
- });
49
- });
50
- describe('nativeLynxSDKVersionLessThan', ()=>{
51
- beforeEach(()=>{
52
- global.SystemInfo = createMockSystemInfo('1.2.3');
53
- });
54
- it('should return true when native version is less', ()=>{
55
- global.SystemInfo = createMockSystemInfo('1.2.2');
56
- expect(nativeLynxSDKVersionLessThan('1.2.3')).toBe(true);
57
- });
58
- it('should return false when native version is equal', ()=>{
59
- global.SystemInfo = createMockSystemInfo('1.2.3');
60
- expect(nativeLynxSDKVersionLessThan('1.2.3')).toBe(false);
61
- });
62
- it('should return false when native version is greater', ()=>{
63
- global.SystemInfo = createMockSystemInfo('1.2.4');
64
- expect(nativeLynxSDKVersionLessThan('1.2.3')).toBe(false);
65
- });
66
- it('should handle major version differences', ()=>{
67
- global.SystemInfo = createMockSystemInfo('1.0.0');
68
- expect(nativeLynxSDKVersionLessThan('2.0.0')).toBe(true);
69
- });
70
- it('should handle minor version differences', ()=>{
71
- global.SystemInfo = createMockSystemInfo('1.1.0');
72
- expect(nativeLynxSDKVersionLessThan('1.2.0')).toBe(true);
73
- });
74
- });
75
- });
76
-
77
- //# sourceMappingURL=version.test.jsx.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils/version.test.jsx","sources":["../../src/utils/version.test.ts"],"sourcesContent":["// Copyright 2026 The Lynx Authors. All rights reserved.\n// Licensed under the Apache License Version 2.0 that can be found in the\n// LICENSE file in the root directory of this source tree.\n\nimport { describe, it, expect, beforeEach } from 'vitest'\nimport {\n lynxSDKVersionStringToNumber,\n nativeLynxSDKVersionGreaterThan,\n nativeLynxSDKVersionLessThan,\n} from './version'\n\nfunction createMockSystemInfo(lynxSdkVersion: string): typeof SystemInfo {\n return {\n lynxSdkVersion,\n osVersion: '1.0',\n pixelHeight: 100,\n pixelWidth: 100,\n pixelRatio: 1,\n platform: 'Android',\n runtimeType: 'quickjs',\n }\n}\n\ndescribe('version utils', () => {\n describe('lynxSDKVersionStringToNumber', () => {\n it('should convert version string to number correctly', () => {\n expect(lynxSDKVersionStringToNumber('1.2.3')).toBe(10203)\n expect(lynxSDKVersionStringToNumber('2.0.0')).toBe(20000)\n expect(lynxSDKVersionStringToNumber('0.1.0')).toBe(100)\n })\n\n it('should handle missing version parts', () => {\n expect(lynxSDKVersionStringToNumber('1')).toBe(10000)\n expect(lynxSDKVersionStringToNumber('1.2')).toBe(10200)\n expect(lynxSDKVersionStringToNumber('')).toBe(0)\n })\n\n it('should handle version strings with leading zeros', () => {\n expect(lynxSDKVersionStringToNumber('01.02.03')).toBe(10203)\n })\n\n it('should handle large version numbers', () => {\n expect(lynxSDKVersionStringToNumber('99.99.99')).toBe(999999)\n })\n })\n\n describe('nativeLynxSDKVersionGreaterThan', () => {\n beforeEach(() => {\n global.SystemInfo = createMockSystemInfo('1.2.3')\n })\n\n it('should return true when native version is greater', () => {\n global.SystemInfo = createMockSystemInfo('1.2.4')\n expect(nativeLynxSDKVersionGreaterThan('1.2.3')).toBe(true)\n })\n\n it('should return false when native version is equal', () => {\n global.SystemInfo = createMockSystemInfo('1.2.3')\n expect(nativeLynxSDKVersionGreaterThan('1.2.3')).toBe(false)\n })\n\n it('should return false when native version is less', () => {\n global.SystemInfo = createMockSystemInfo('1.2.2')\n expect(nativeLynxSDKVersionGreaterThan('1.2.3')).toBe(false)\n })\n })\n\n describe('nativeLynxSDKVersionLessThan', () => {\n beforeEach(() => {\n global.SystemInfo = createMockSystemInfo('1.2.3')\n })\n\n it('should return true when native version is less', () => {\n global.SystemInfo = createMockSystemInfo('1.2.2')\n expect(nativeLynxSDKVersionLessThan('1.2.3')).toBe(true)\n })\n\n it('should return false when native version is equal', () => {\n global.SystemInfo = createMockSystemInfo('1.2.3')\n expect(nativeLynxSDKVersionLessThan('1.2.3')).toBe(false)\n })\n\n it('should return false when native version is greater', () => {\n global.SystemInfo = createMockSystemInfo('1.2.4')\n expect(nativeLynxSDKVersionLessThan('1.2.3')).toBe(false)\n })\n\n it('should handle major version differences', () => {\n global.SystemInfo = createMockSystemInfo('1.0.0')\n expect(nativeLynxSDKVersionLessThan('2.0.0')).toBe(true)\n })\n\n it('should handle minor version differences', () => {\n global.SystemInfo = createMockSystemInfo('1.1.0')\n expect(nativeLynxSDKVersionLessThan('1.2.0')).toBe(true)\n })\n })\n})\n"],"names":["createMockSystemInfo","lynxSdkVersion","describe","it","expect","lynxSDKVersionStringToNumber","beforeEach","global","nativeLynxSDKVersionGreaterThan","nativeLynxSDKVersionLessThan"],"mappings":";;AAWA,SAASA,qBAAqBC,cAAsB;IAClD,OAAO;QACLA;QACA,WAAW;QACX,aAAa;QACb,YAAY;QACZ,YAAY;QACZ,UAAU;QACV,aAAa;IACf;AACF;AAEAC,SAAS,iBAAiB;IACxBA,SAAS,gCAAgC;QACvCC,GAAG,qDAAqD;YACtDC,OAAOC,6BAA6B,UAAU,IAAI,CAAC;YACnDD,OAAOC,6BAA6B,UAAU,IAAI,CAAC;YACnDD,OAAOC,6BAA6B,UAAU,IAAI,CAAC;QACrD;QAEAF,GAAG,uCAAuC;YACxCC,OAAOC,6BAA6B,MAAM,IAAI,CAAC;YAC/CD,OAAOC,6BAA6B,QAAQ,IAAI,CAAC;YACjDD,OAAOC,6BAA6B,KAAK,IAAI,CAAC;QAChD;QAEAF,GAAG,oDAAoD;YACrDC,OAAOC,6BAA6B,aAAa,IAAI,CAAC;QACxD;QAEAF,GAAG,uCAAuC;YACxCC,OAAOC,6BAA6B,aAAa,IAAI,CAAC;QACxD;IACF;IAEAH,SAAS,mCAAmC;QAC1CI,WAAW;YACTC,OAAO,UAAU,GAAGP,qBAAqB;QAC3C;QAEAG,GAAG,qDAAqD;YACtDI,OAAO,UAAU,GAAGP,qBAAqB;YACzCI,OAAOI,gCAAgC,UAAU,I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