@onekeyfe/cross-inpage-provider-injected 2.2.60 → 2.2.62

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.
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ /* eslint-disable @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access */
3
+ // Unit tests for webpack stub modules used to replace heavy dependencies
4
+ // in the injected bundle. These stubs must maintain API compatibility
5
+ // with the subset of functionality actually used at runtime.
6
+ describe('validator-stub', () => {
7
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
8
+ const validator = require('../validator-stub');
9
+ describe('isURL', () => {
10
+ it('should accept valid HTTP/HTTPS URLs', () => {
11
+ expect(validator.isURL('https://api.trongrid.io')).toBe(true);
12
+ expect(validator.isURL('http://localhost:8090')).toBe(true);
13
+ expect(validator.isURL('https://node.mainnet.alephium.org')).toBe(true);
14
+ });
15
+ it('should reject non-URL strings', () => {
16
+ expect(validator.isURL('not-a-url')).toBe(false);
17
+ expect(validator.isURL('')).toBe(false);
18
+ expect(validator.isURL('ftp://files.example.com')).toBe(false);
19
+ });
20
+ it('should reject non-string input', () => {
21
+ expect(validator.isURL(null)).toBe(false);
22
+ expect(validator.isURL(undefined)).toBe(false);
23
+ expect(validator.isURL(123)).toBe(false);
24
+ });
25
+ it('should respect custom protocols option', () => {
26
+ expect(validator.isURL('ftp://files.example.com', { protocols: ['ftp'] })).toBe(true);
27
+ expect(validator.isURL('https://example.com', { protocols: ['ftp'] })).toBe(false);
28
+ });
29
+ });
30
+ });
31
+ describe('alephium-web3-stub', () => {
32
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
33
+ const alph = require('../../../../providers/onekey-alph-provider/src/stubs/alephium-web3');
34
+ it('should export SignerProvider and InteractiveSignerProvider', () => {
35
+ expect(alph.SignerProvider).toBeDefined();
36
+ expect(alph.InteractiveSignerProvider).toBeDefined();
37
+ expect(alph.InteractiveSignerProvider.prototype).toBeInstanceOf(alph.SignerProvider);
38
+ });
39
+ it('should not export NodeProvider/ExplorerProvider (type-only imports, erased by TS)', () => {
40
+ expect(alph.NodeProvider).toBeUndefined();
41
+ expect(alph.ExplorerProvider).toBeUndefined();
42
+ });
43
+ it('should support duck-typing checks', () => {
44
+ const instance = new alph.InteractiveSignerProvider();
45
+ expect('getSelectedAccount' in instance).toBe(true);
46
+ expect('enable' in instance).toBe(true);
47
+ });
48
+ });