From d0524f6180ca90c40561c79c9f910d815c723973 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 17 May 2026 15:57:22 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=A7=AA=20test:=20add=20coverage=20for?= =?UTF-8?q?=20constants=20logic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: sunnylqm <615282+sunnylqm@users.noreply.github.com> --- tests/constants.test.ts | 42 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 tests/constants.test.ts diff --git a/tests/constants.test.ts b/tests/constants.test.ts new file mode 100644 index 0000000..2bf7f17 --- /dev/null +++ b/tests/constants.test.ts @@ -0,0 +1,42 @@ +import { describe, expect, it } from 'bun:test'; + +const loadConstantsWithArgv = async (argv1: string) => { + const originalArgv = process.argv; + process.argv = ['node', argv1]; + const url = `../src/utils/constants.ts?t=${Date.now()}_${Math.random()}`; + const mod = await import(url); + process.argv = originalArgv; + return mod; +}; + +describe('constants', () => { + it('should initialize correctly when script is cresc', async () => { + const mod = await loadConstantsWithArgv('/usr/local/bin/cresc'); + expect(mod.scriptName).toBe('cresc'); + expect(mod.IS_CRESC).toBe(true); + expect(mod.credentialFile).toBe('.cresc.token'); + expect(mod.updateJson).toBe('cresc.config.json'); + expect(mod.tempDir).toBe('.cresc.temp'); + expect(mod.pricingPageUrl).toBe('https://cresc.dev/pricing'); + expect(mod.defaultEndpoints).toEqual(['https://api.cresc.dev', 'https://api.cresc.app']); + }); + + it('should initialize correctly when script is pushy', async () => { + const mod = await loadConstantsWithArgv('/usr/local/bin/pushy'); + expect(mod.scriptName).toBe('pushy'); + expect(mod.IS_CRESC).toBe(false); + expect(mod.credentialFile).toBe('.update'); + expect(mod.updateJson).toBe('update.json'); + expect(mod.tempDir).toBe('.pushy'); + expect(mod.pricingPageUrl).toBe('https://pushy.reactnative.cn/pricing.html'); + expect(mod.defaultEndpoints).toEqual(['https://update.reactnative.cn/api', 'https://update.react-native.cn/api']); + }); + + it('should identify PPK bundle file names correctly', async () => { + const { isPPKBundleFileName } = await import('../src/utils/constants.ts'); + expect(isPPKBundleFileName('index.bundlejs')).toBe(true); + expect(isPPKBundleFileName('bundle.harmony.js')).toBe(true); + expect(isPPKBundleFileName('index.js')).toBe(false); + expect(isPPKBundleFileName('main.bundlejs')).toBe(false); + }); +}); From 56ed8627390be60ab6b2a8ceb7acc4f7a64361e3 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 17 May 2026 15:59:01 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A7=AA=20test:=20add=20coverage=20for?= =?UTF-8?q?=20constants=20logic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: sunnylqm <615282+sunnylqm@users.noreply.github.com> --- tests/constants.test.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/constants.test.ts b/tests/constants.test.ts index 2bf7f17..fcaefed 100644 --- a/tests/constants.test.ts +++ b/tests/constants.test.ts @@ -18,7 +18,10 @@ describe('constants', () => { expect(mod.updateJson).toBe('cresc.config.json'); expect(mod.tempDir).toBe('.cresc.temp'); expect(mod.pricingPageUrl).toBe('https://cresc.dev/pricing'); - expect(mod.defaultEndpoints).toEqual(['https://api.cresc.dev', 'https://api.cresc.app']); + expect(mod.defaultEndpoints).toEqual([ + 'https://api.cresc.dev', + 'https://api.cresc.app', + ]); }); it('should initialize correctly when script is pushy', async () => { @@ -28,8 +31,13 @@ describe('constants', () => { expect(mod.credentialFile).toBe('.update'); expect(mod.updateJson).toBe('update.json'); expect(mod.tempDir).toBe('.pushy'); - expect(mod.pricingPageUrl).toBe('https://pushy.reactnative.cn/pricing.html'); - expect(mod.defaultEndpoints).toEqual(['https://update.reactnative.cn/api', 'https://update.react-native.cn/api']); + expect(mod.pricingPageUrl).toBe( + 'https://pushy.reactnative.cn/pricing.html', + ); + expect(mod.defaultEndpoints).toEqual([ + 'https://update.reactnative.cn/api', + 'https://update.react-native.cn/api', + ]); }); it('should identify PPK bundle file names correctly', async () => {