-
Notifications
You must be signed in to change notification settings - Fork 905
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: xcworkspaces parsing should handle many xcprojects (#2522)
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
packages/cli-platform-apple/src/tools/__tests__/getInfo.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import type {IOSProjectInfo} from '@react-native-community/cli-types'; | ||
|
||
import execa from 'execa'; | ||
import fs from 'fs'; | ||
import {getInfo} from '../getInfo'; | ||
|
||
jest.mock('execa', () => ({ | ||
sync: jest.fn(), | ||
})); | ||
|
||
jest.mock('fs', () => ({ | ||
readFileSync: jest.fn(), | ||
})); | ||
|
||
describe('getInfo', () => { | ||
it('handles non-project / workspace locations in a ', () => { | ||
const name = `YourProjectName`; | ||
(fs.readFileSync as jest.Mock) | ||
.mockReturnValueOnce(`<?xml version="1.0" encoding="UTF-8"?> | ||
<Workspace | ||
version = "1.0"> | ||
<FileRef | ||
location = "group:${name}.xcodeproj"> | ||
</FileRef> | ||
<FileRef | ||
location = "group:Pods/Pods.xcodeproj"> | ||
</FileRef> | ||
<FileRef | ||
location = "group:container/some_other_file.mm"> | ||
</FileRef> | ||
</Workspace>`); | ||
(execa.sync as jest.Mock).mockReturnValue({stdout: '{}'}); | ||
getInfo({isWorkspace: true, name} as IOSProjectInfo, 'some/path'); | ||
|
||
const execaSync = execa.sync as jest.Mock; | ||
// Should not call on Pods or the other misc groups | ||
expect(execaSync.mock.calls).toEqual([ | ||
[ | ||
'xcodebuild', | ||
['-list', '-json', '-project', `some/path/${name}.xcodeproj`], | ||
], | ||
]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters