From 54f8d618c3b702fe26f3ecc8db350ee1260b2548 Mon Sep 17 00:00:00 2001 From: GhostCoder6969 Date: Mon, 5 Oct 2026 00:08:35 +0000 Subject: [PATCH] test: cover codePushGradlePath gradle expression --- .../__tests__/code-push-gradle-path.test.ts | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/utils/__tests__/code-push-gradle-path.test.ts diff --git a/src/utils/__tests__/code-push-gradle-path.test.ts b/src/utils/__tests__/code-push-gradle-path.test.ts new file mode 100644 index 0000000..cc31435 --- /dev/null +++ b/src/utils/__tests__/code-push-gradle-path.test.ts @@ -0,0 +1,28 @@ +import { codePushGradlePath } from "../code-push-gradle-path"; + +describe("codePushGradlePath", () => { + it("builds the full gradle expression", () => { + expect(codePushGradlePath("android/codepush.gradle")).toBe( + `new File(new File(["node", "--print", "require.resolve('react-native-code-push/package.json')"].execute(null, rootDir).text.trim()).parentFile, "android/codepush.gradle")`, + ); + }); + + it("embeds the given relative path", () => { + expect(codePushGradlePath("android")).toContain('"android"'); + }); + + it("resolves the package through node instead of a hardcoded path", () => { + expect(codePushGradlePath("android/codepush.gradle")).toContain( + "require.resolve('react-native-code-push/package.json')", + ); + expect(codePushGradlePath("android/codepush.gradle")).not.toContain( + "../../node_modules", + ); + }); + + it("points different files at different paths", () => { + expect(codePushGradlePath("android/codepush.gradle")).not.toBe( + codePushGradlePath("android"), + ); + }); +});