From f97c25807d634d160cdb0f311ef4d3a78e4b8cf5 Mon Sep 17 00:00:00 2001 From: Roy Li Date: Sat, 13 Apr 2024 14:10:36 +0200 Subject: [PATCH] test: change test --- src/provider/V2rayNSubscribeProvider.ts | 2 +- src/provider/__tests__/ClashProvider.test.ts | 4 +- .../__snapshots__/ClashProvider.test.ts.md | 173 ++++++++++++++++++ .../__snapshots__/ClashProvider.test.ts.snap | Bin 0 -> 1579 bytes 4 files changed, 175 insertions(+), 4 deletions(-) create mode 100644 src/provider/__tests__/__snapshots__/ClashProvider.test.ts.md create mode 100644 src/provider/__tests__/__snapshots__/ClashProvider.test.ts.snap diff --git a/src/provider/V2rayNSubscribeProvider.ts b/src/provider/V2rayNSubscribeProvider.ts index 0b74a26e7..18e841598 100644 --- a/src/provider/V2rayNSubscribeProvider.ts +++ b/src/provider/V2rayNSubscribeProvider.ts @@ -163,7 +163,7 @@ export const getV2rayNSubscription = async ({ export const parseJSONConfig = ( json: string, - isCompatibleMode: boolean | undefined, + isCompatibleMode?: boolean | undefined, skipCertVerify?: boolean | undefined, udpRelay?: boolean | undefined, tls13?: boolean | undefined, diff --git a/src/provider/__tests__/ClashProvider.test.ts b/src/provider/__tests__/ClashProvider.test.ts index 0d0dee4a2..670f975d3 100644 --- a/src/provider/__tests__/ClashProvider.test.ts +++ b/src/provider/__tests__/ClashProvider.test.ts @@ -24,9 +24,7 @@ test('ClashProvider', async (t) => { }) t.is(provider.type, SupportProviderEnum.Clash) - await t.notThrowsAsync(async () => { - await provider.getNodeList() - }) + t.snapshot(await provider.getNodeList()) }) test('ClashProvider new format', async (t) => { diff --git a/src/provider/__tests__/__snapshots__/ClashProvider.test.ts.md b/src/provider/__tests__/__snapshots__/ClashProvider.test.ts.md new file mode 100644 index 000000000..fb0c6d9a5 --- /dev/null +++ b/src/provider/__tests__/__snapshots__/ClashProvider.test.ts.md @@ -0,0 +1,173 @@ +# Snapshot report for `src/provider/__tests__/ClashProvider.test.ts` + +The actual snapshot is saved in `ClashProvider.test.ts.snap`. + +Generated by [AVA](https://avajs.dev). + +## ClashProvider + +> Snapshot 1 + + [ + { + hostname: 'server', + method: 'chacha20-ietf-poly1305', + nodeName: 'ss1', + password: 'password', + port: 443, + type: 'shadowsocks', + udpRelay: true, + }, + { + hostname: 'server', + method: 'chacha20-ietf-poly1305', + nodeName: 'ss2', + obfs: 'tls', + obfsHost: 'www.bing.com', + password: 'password', + port: 443, + type: 'shadowsocks', + udpRelay: false, + }, + { + hostname: 'server', + method: 'chacha20-ietf-poly1305', + nodeName: 'ss3', + obfs: 'ws', + obfsHost: 'server', + obfsUri: '/', + password: 'password', + port: 443, + type: 'shadowsocks', + udpRelay: false, + wsHeaders: {}, + }, + { + alterId: '32', + hostname: 'server', + method: 'auto', + network: 'tcp', + nodeName: 'vmess', + port: 443, + tls: false, + type: 'vmess', + udpRelay: false, + uuid: 'uuid', + }, + { + alterId: '32', + hostname: 'server', + method: 'auto', + network: 'ws', + nodeName: 'vmess new format', + port: 443, + skipCertVerify: true, + tls: true, + tls13: false, + type: 'vmess', + udpRelay: true, + uuid: 'uuid', + wsOpts: { + 'early-data-header-name': 'Sec-WebSocket-Protocol', + headers: { + Host: 'v2ray.com', + }, + 'max-early-data': 2048, + path: '/path', + }, + }, + { + alterId: '32', + hostname: 'server', + method: 'auto', + network: 'ws', + nodeName: 'vmess custom header', + port: 443, + skipCertVerify: false, + tls: true, + tls13: false, + type: 'vmess', + udpRelay: false, + uuid: 'uuid', + wsOpts: { + headers: { + edge: 'www.baidu.com', + }, + path: '/path', + }, + }, + { + hostname: 'server', + nodeName: 'socks', + port: 443, + type: 'socks5', + }, + { + hostname: 'server', + nodeName: 'http 1', + password: 'password', + port: 443, + skipCertVerify: false, + tls13: false, + type: 'https', + username: 'username', + }, + { + hostname: 'server', + nodeName: 'http 2', + password: 'password', + port: 443, + type: 'http', + username: 'username', + }, + { + hostname: 'server', + nodeName: 'snell', + obfs: 'http', + port: 44046, + psk: 'yourpsk', + type: 'snell', + }, + { + hostname: 'server', + method: 'chacha20-ietf-poly1305', + nodeName: 'ss4', + obfs: 'tls', + obfsHost: 'example.com', + password: 'password', + port: 443, + type: 'shadowsocks', + udpRelay: false, + }, + { + hostname: 'server', + method: 'chacha20-ietf-poly1305', + nodeName: 'ss-wss', + obfs: 'wss', + obfsHost: 'cloudflare.com', + obfsUri: '/ws', + password: 'password', + port: 443, + skipCertVerify: false, + tls13: false, + type: 'shadowsocks', + udpRelay: false, + wsHeaders: {}, + }, + { + alpn: [ + 'h3', + ], + downloadBandwidth: 200, + hostname: 'server.com', + nodeName: 'hysteria2', + obfs: 'salamander', + obfsPassword: 'yourpassword', + password: 'yourpassword', + port: 443, + skipCertVerify: false, + sni: 'server.com', + type: 'hysteria2', + uploadBandwidth: 30, + }, + ] diff --git a/src/provider/__tests__/__snapshots__/ClashProvider.test.ts.snap b/src/provider/__tests__/__snapshots__/ClashProvider.test.ts.snap new file mode 100644 index 0000000000000000000000000000000000000000..23f6a52c924fbe11d6b51dd1f461143e7fb8da2f GIT binary patch literal 1579 zcmV+`2GsdMRzVIaZ}^tkyv@?R`fk^rZ5XE8@LIa# z)otH9FlQLLuRk&mIat05hkl9p`3*6 zNpR-vmy+;)5>6)JToSHH!HyI(Qt)(2fQyT8nYU8#P71zA!EY(3C~%_!4=eDv0tXfN zP=OPQ040l1>hB7iSKz8N+>wSx8lFkR$7%R34Hwcdnt{m-?8!ho121O;*klCu(0s@T z^C2fPa6SWLS-3R|vsrjC3m;|S>n!|~1uX~TIoO>OVACROqMn0R4i4tvXb!#=Lvmt> zaxMpw3fHT!ONIR^98}?m3Mb~dedC`AbX}eYr2A)+%)~V zZ7em1YjwR=*SBu2HcWrI>eyCy%f#kwB6iC*%)3`$4|(1e(Z|s}uVcGL6n;p znx44mHJJ-`PLGV$IUNWbWwRfk-EJ6tjgZsa2I6!;UW=4!;mXHaW@l{LcAL8YSJ+j( znTB(l>H2$2w=unZo~|N+*pu)rZ_C6w$s>Xfl1G)K;_&irkUQQk$M^n^vXvHOtF=Af zZjRN%J^hcB6E*mcl)IFTrApH6t0))$d%8pqmq91$r60?37``o>Qfi&1B-ef48T)st zrAx|yOV>G=X;f#=bXP9B_aS6SURRbP+jISI-gq$3IW$J}47y`AAzYwv96@Z1WAxNbQu0kvS*ot9AlqdMjFLWCOR|f?V0~NEs|y zMBBBT*P)Q{T8)d-(x>#Ql;qpa06nBDgImAv*(DKqQ+t0H4iCeHVHg>Kn@5C~nv@ta z^ymmokHC|nYesPG?=6WyvAGd=d!+waxzhKnJfM^sHg(tPR)bgV>OzfKU72CS_nNip z1LoAdc5TM=tGiv>w`;Z)Cian$<-|_bm-4<}x~9Irx;(<7!idFF+|d_V4tDBz&{78+mMt+zcyENo97ct9KWY dageWR?Ca5;3txEjhS3iE{{(=7AvTs6008~d5>EgC literal 0 HcmV?d00001