|
1 | 1 | import fs from "fs"; |
2 | 2 | import path from "path"; |
3 | 3 |
|
4 | | -describe("react-native config", () => { |
5 | | - it("exposes podspec path and android package", () => { |
6 | | - const config = require("../react-native.config.js"); |
7 | | - expect(config).toHaveProperty("dependency.platforms.ios.podspec"); |
8 | | - expect(config).toHaveProperty("dependency.platforms.android.packageImportPath", "com.contactsupdated.ContactsLastUpdatedPackage"); |
9 | | - expect(config).toHaveProperty("dependency.platforms.android.packageInstance", "new ContactsLastUpdatedPackage()"); |
| 4 | +describe("package metadata", () => { |
| 5 | + const root = path.resolve(__dirname, ".."); |
10 | 6 |
|
11 | | - const podspecPath = config.dependency.platforms.ios.podspec as string; |
12 | | - const resolved = path.resolve(__dirname, "..", podspecPath); |
13 | | - expect(fs.existsSync(resolved)).toBe(true); |
14 | | - }); |
15 | | - |
16 | | - it("includes podspec and config in published files", () => { |
| 7 | + it("ships the podspec in the published files", () => { |
17 | 8 | const pkg = require("../package.json"); |
18 | 9 | expect(pkg.files).toEqual( |
19 | | - expect.arrayContaining([ |
20 | | - "react-native-contacts-last-updated.podspec", |
21 | | - "react-native.config.js", |
22 | | - ]) |
| 10 | + expect.arrayContaining(["react-native-contacts-last-updated.podspec"]) |
| 11 | + ); |
| 12 | + expect(pkg.files).not.toEqual( |
| 13 | + expect.arrayContaining(["react-native.config.js"]) |
| 14 | + ); |
| 15 | + }); |
| 16 | + |
| 17 | + it("defines iOS sources in the podspec", () => { |
| 18 | + const podspec = fs.readFileSync( |
| 19 | + path.join(root, "react-native-contacts-last-updated.podspec"), |
| 20 | + "utf8" |
| 21 | + ); |
| 22 | + expect(podspec).toMatch(/s\.source_files\s*=\s*"ios\/\*\*\/\*\.\{h,m,mm,swift}/); |
| 23 | + }); |
| 24 | + |
| 25 | + it("exposes an Android ReactPackage", () => { |
| 26 | + const pkgSource = fs.readFileSync( |
| 27 | + path.join( |
| 28 | + root, |
| 29 | + "android", |
| 30 | + "src", |
| 31 | + "main", |
| 32 | + "java", |
| 33 | + "com", |
| 34 | + "contactsupdated", |
| 35 | + "ContactsLastUpdatedPackage.kt" |
| 36 | + ), |
| 37 | + "utf8" |
23 | 38 | ); |
| 39 | + expect(pkgSource).toContain("class ContactsLastUpdatedPackage : ReactPackage"); |
24 | 40 | }); |
25 | 41 | }); |
0 commit comments