Skip to content

Commit ab9cd5a

Browse files
committed
Simplify scheme newline tests
1 parent 8ee8509 commit ab9cd5a

3 files changed

Lines changed: 8 additions & 18 deletions

File tree

‎packages/react-native/scripts/spm/__tests__/generate-spm-xcodeproj-test.js‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,10 @@ describe('scheme pre-action', () => {
139139
});
140140

141141
function parsedSyncScript(xml) {
142-
const contents = new DOMParser()
142+
return new DOMParser()
143143
.parseFromString(xml, 'text/xml')
144-
.getElementsByTagName('ActionContent');
145-
for (let i = 0; i < contents.length; i++) {
146-
if (contents[i].getAttribute('title') === 'Sync SPM Autolinking') {
147-
return contents[i].getAttribute('scriptText');
148-
}
149-
}
150-
return null;
144+
.getElementsByTagName('ActionContent')[0]
145+
.getAttribute('scriptText');
151146
}
152147

153148
const MULTILINE_SCRIPT = 'set -e\n\tif [ "$A" ]; then\r\n a && b < c\nfi';
@@ -174,7 +169,6 @@ describe('scheme pre-action', () => {
174169
'TARGET_UUID',
175170
MULTILINE_SCRIPT,
176171
);
177-
expect(updated).toContain('&#10;');
178172
expect(parsedSyncScript(updated)).toBe(MULTILINE_SCRIPT);
179173
});
180174

‎packages/react-native/scripts/spm/__tests__/remove-spm-injection-test.js‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -505,10 +505,9 @@ describe('deinit — scheme ownership', () => {
505505
sync();
506506
fs.writeFileSync(
507507
schemePath,
508-
readScheme()
509-
.replace(/&#10;/g, '\n')
510-
.replace(/&#13;/g, '\r')
511-
.replace(/&#9;/g, '\t'),
508+
readScheme().replace(/&#(9|10|13);/g, (_, c) =>
509+
String.fromCharCode(Number(c)),
510+
),
512511
'utf8',
513512
);
514513

‎packages/react-native/scripts/spm/generate-spm-xcodeproj.js‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2518,11 +2518,8 @@ function injectSpmIntoExistingXcodeproj(
25182518
return {status: 'injected', target: plan.target.name};
25192519
}
25202520

2521-
/**
2522-
* The scheme with the sync pre-action's scriptText emptied, or null when the
2523-
* scheme has none. Cutting the raw value keeps the comparison independent of
2524-
* how an older RN version encoded the script.
2525-
*/
2521+
// The scheme with the sync pre-action's scriptText emptied, so the compare
2522+
// ignores how the script was encoded; null when there is no pre-action.
25262523
function withoutPreActionScript(xml /*: string */) /*: ?string */ {
25272524
const titleIdx = xml.indexOf('title = "Sync SPM Autolinking"');
25282525
if (titleIdx < 0) {

0 commit comments

Comments
 (0)