From afc2e13b42540332210f4d95f1176c0bb5770911 Mon Sep 17 00:00:00 2001 From: EmmaYuan1015 Date: Fri, 3 Jul 2026 09:16:01 +0800 Subject: [PATCH] test: update setNewArch noop/idempotent cases --- test/extension/commands/setNewArch.test.ts | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/test/extension/commands/setNewArch.test.ts b/test/extension/commands/setNewArch.test.ts index 19f1e6773..22c6e2bb1 100644 --- a/test/extension/commands/setNewArch.test.ts +++ b/test/extension/commands/setNewArch.test.ts @@ -202,6 +202,45 @@ suite("setNewArchCommand", function () { assert.strictEqual(spawnStub.calledWithExactly("pod", ["install"]), true); }); + test("should not write or install pods when enabling iOS new architecture and disable line is already absent", async function () { + const iosPath = path.join(tempDir, "ios"); + const podfilePath = path.join(iosPath, "Podfile"); + fs.mkdirSync(iosPath, { recursive: true }); + fs.writeFileSync(podfilePath, "use_react_native!(:path => config[:reactNativePath])"); + const showQuickPickStub = Sinon.stub(); + showQuickPickStub.onFirstCall().returns(Promise.resolve("iOS")); + showQuickPickStub.onSecondCall().returns(Promise.resolve("true")); + const writeFileStub = Sinon.stub().returns(Promise.resolve()); + const spawnStub = Sinon.stub().returns(Promise.resolve()); + const { SetNewArch } = createCommandModule(showQuickPickStub, writeFileStub, spawnStub); + + await runCommand(SetNewArch); + + assert.strictEqual(writeFileStub.called, false); + assert.strictEqual(spawnStub.called, false); + }); + + test("should not write or install pods when disabling iOS new architecture and disable line already exists", async function () { + const iosPath = path.join(tempDir, "ios"); + const podfilePath = path.join(iosPath, "Podfile"); + fs.mkdirSync(iosPath, { recursive: true }); + fs.writeFileSync( + podfilePath, + "ENV['RCT_NEW_ARCH_ENABLED'] = '0'\nuse_react_native!(:path => config[:reactNativePath])", + ); + const showQuickPickStub = Sinon.stub(); + showQuickPickStub.onFirstCall().returns(Promise.resolve("iOS")); + showQuickPickStub.onSecondCall().returns(Promise.resolve("false")); + const writeFileStub = Sinon.stub().returns(Promise.resolve()); + const spawnStub = Sinon.stub().returns(Promise.resolve()); + const { SetNewArch } = createCommandModule(showQuickPickStub, writeFileStub, spawnStub); + + await runCommand(SetNewArch); + + assert.strictEqual(writeFileStub.called, false); + assert.strictEqual(spawnStub.called, false); + }); + test("should return without writing when the platform selection is cancelled", async function () { const showQuickPickStub = Sinon.stub(); showQuickPickStub.onFirstCall().returns(Promise.resolve(undefined));