|
1 | 1 | /* eslint-disable simple-import-sort/imports */ |
2 | | -import { describe, it, expect } from "@jest/globals"; |
| 2 | +import { describe, it, expect, beforeEach, afterEach } from "@jest/globals"; |
3 | 3 |
|
4 | | -import { formatKeychainChoiceLabelPlain } from "../../src/utils/formatting"; |
| 4 | +import { |
| 5 | + formatKeychainChoiceLabelPlain, |
| 6 | + getKeyStorageMessage, |
| 7 | +} from "../../src/utils/formatting"; |
5 | 8 |
|
6 | 9 | describe("formatKeychainChoiceLabel", () => { |
7 | 10 | it("includes name and endpoint, excludes id", () => { |
@@ -49,3 +52,72 @@ describe("formatKeychainChoiceLabel", () => { |
49 | 52 | expect(label).toContain("Sends: Off"); |
50 | 53 | }); |
51 | 54 | }); |
| 55 | + |
| 56 | +describe("getKeyStorageMessage", () => { |
| 57 | + let originalPlatform: string; |
| 58 | + |
| 59 | + beforeEach(() => { |
| 60 | + originalPlatform = process.platform; |
| 61 | + }); |
| 62 | + |
| 63 | + afterEach(() => { |
| 64 | + Object.defineProperty(process, "platform", { |
| 65 | + value: originalPlatform, |
| 66 | + writable: true, |
| 67 | + configurable: true, |
| 68 | + }); |
| 69 | + }); |
| 70 | + |
| 71 | + it("returns macOS Keychain message on darwin", () => { |
| 72 | + Object.defineProperty(process, "platform", { |
| 73 | + value: "darwin", |
| 74 | + writable: true, |
| 75 | + configurable: true, |
| 76 | + }); |
| 77 | + expect(getKeyStorageMessage()).toBe( |
| 78 | + "Keys are stored securely in macOS Keychain" |
| 79 | + ); |
| 80 | + }); |
| 81 | + |
| 82 | + it("returns file message on win32", () => { |
| 83 | + Object.defineProperty(process, "platform", { |
| 84 | + value: "win32", |
| 85 | + writable: true, |
| 86 | + configurable: true, |
| 87 | + }); |
| 88 | + expect(getKeyStorageMessage()).toBe( |
| 89 | + "Keys are stored in ~/.iterable-mcp/keys.json" |
| 90 | + ); |
| 91 | + }); |
| 92 | + |
| 93 | + it("returns file with permissions message on linux", () => { |
| 94 | + Object.defineProperty(process, "platform", { |
| 95 | + value: "linux", |
| 96 | + writable: true, |
| 97 | + configurable: true, |
| 98 | + }); |
| 99 | + expect(getKeyStorageMessage()).toBe( |
| 100 | + "Keys are stored in ~/.iterable-mcp/keys.json with restricted permissions" |
| 101 | + ); |
| 102 | + }); |
| 103 | + |
| 104 | + it("adds bullet point prefix when requested", () => { |
| 105 | + Object.defineProperty(process, "platform", { |
| 106 | + value: "darwin", |
| 107 | + writable: true, |
| 108 | + configurable: true, |
| 109 | + }); |
| 110 | + expect(getKeyStorageMessage(true)).toBe( |
| 111 | + "• Keys are stored securely in macOS Keychain" |
| 112 | + ); |
| 113 | + }); |
| 114 | + |
| 115 | + it("omits bullet point by default", () => { |
| 116 | + Object.defineProperty(process, "platform", { |
| 117 | + value: "darwin", |
| 118 | + writable: true, |
| 119 | + configurable: true, |
| 120 | + }); |
| 121 | + expect(getKeyStorageMessage()).not.toContain("• "); |
| 122 | + }); |
| 123 | +}); |
0 commit comments