| 69 | }; |
| 70 | |
| 71 | const expectLaunchdInvariants = (plist: string, input: typeof launchdInput): void => { |
| 72 | const programArguments = input.programArguments |
| 73 | .map((arg) => ` <string>${arg}</string>`) |
| 74 | .join("\n"); |
| 75 | |
| 76 | expect(plist).toContain("<key>Label</key>"); |
| 77 | expect(plist).toContain(`<string>${input.label}</string>`); |
| 78 | expect(plist).toContain( |
| 79 | ` <key>ProgramArguments</key>\n <array>\n${programArguments}\n </array>`, |
| 80 | ); |
| 81 | expect(plist).toMatch(/<key>RunAtLoad<\/key>\s*<true\/>/); |
| 82 | expect(plist).toMatch( |
| 83 | /<key>KeepAlive<\/key>\s*<dict>\s*<key>SuccessfulExit<\/key>\s*<false\/>\s*<\/dict>/, |
| 84 | ); |
| 85 | }; |
| 86 | |
| 87 | it("renders a launchd plist that restarts on crash but not clean stop", () => { |
| 88 | const plist = generateLaunchdPlist(launchdInput); |