storebound/tests/entitlements-ref.test.ts

18 lines
1.1 KiB
TypeScript

// The entitlements file the pbxproj names is "referenced" on every OS (Windows paths use backslashes; pitfall 103).
import { expect, test } from 'bun:test';
import { mkdirSync, mkdtempSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { readProjectEntitlements } from '../cli/apple/signing';
test('CODE_SIGN_ENTITLEMENTS = App/App.entitlements matches ios/App/App/App.entitlements', () => {
const root = mkdtempSync(join(tmpdir(), 'sb-ent-'));
mkdirSync(join(root, 'ios/App/App.xcodeproj'), { recursive: true });
mkdirSync(join(root, 'ios/App/App'), { recursive: true });
writeFileSync(join(root, 'ios/App/App.xcodeproj/project.pbxproj'), 'buildSettings = { CODE_SIGN_ENTITLEMENTS = App/App.entitlements; };\n');
writeFileSync(join(root, 'ios/App/App/App.entitlements'), '<plist><dict><key>com.apple.developer.game-center</key><true/></dict></plist>');
const r = readProjectEntitlements(root)!;
expect(r).toHaveLength(1);
expect(r[0]!.file).toBe('ios/App/App/App.entitlements');
expect(r[0]!.referenced).toBe(true);
});