|
1 | 1 | import { |
| 2 | + customProviders, |
| 3 | + dynamicProviders, |
| 4 | + fauxProviders, |
| 5 | + internalProviders, |
| 6 | + isCustomProvider, |
| 7 | + isDynamicProvider, |
| 8 | + isFauxProvider, |
| 9 | + isInternalProvider, |
| 10 | + isLocalProvider, |
2 | 11 | isProviderName, |
3 | 12 | isRetiredProvider, |
| 13 | + localProviders, |
4 | 14 | providerIdentifiers, |
5 | 15 | providerNames, |
6 | 16 | providerNamesSchema, |
@@ -81,6 +91,75 @@ describe("provider identifiers", () => { |
81 | 91 | expect(retiredProviderNames).toEqual(retiredIdentifiers) |
82 | 92 | }) |
83 | 93 |
|
| 94 | + it("derives provider category collections from canonical identifiers", () => { |
| 95 | + expect(dynamicProviders).toEqual([ |
| 96 | + providerIdentifiers.openrouter, |
| 97 | + providerIdentifiers.vercelAiGateway, |
| 98 | + providerIdentifiers.zooGateway, |
| 99 | + providerIdentifiers.litellm, |
| 100 | + providerIdentifiers.requesty, |
| 101 | + providerIdentifiers.unbound, |
| 102 | + providerIdentifiers.poe, |
| 103 | + providerIdentifiers.deepseek, |
| 104 | + providerIdentifiers.moonshot, |
| 105 | + providerIdentifiers.opencodeGo, |
| 106 | + providerIdentifiers.kenari, |
| 107 | + ]) |
| 108 | + expect(localProviders).toEqual([providerIdentifiers.ollama, providerIdentifiers.lmstudio]) |
| 109 | + expect(internalProviders).toEqual([providerIdentifiers.vscodeLm]) |
| 110 | + expect(customProviders).toEqual([providerIdentifiers.openai]) |
| 111 | + expect(fauxProviders).toEqual([providerIdentifiers.fakeAi]) |
| 112 | + }) |
| 113 | + |
| 114 | + it("preserves provider category type guards", () => { |
| 115 | + for (const identifier of dynamicProviders) { |
| 116 | + expect(isDynamicProvider(identifier)).toBe(true) |
| 117 | + } |
| 118 | + |
| 119 | + for (const identifier of localProviders) { |
| 120 | + expect(isLocalProvider(identifier)).toBe(true) |
| 121 | + } |
| 122 | + |
| 123 | + for (const identifier of internalProviders) { |
| 124 | + expect(isInternalProvider(identifier)).toBe(true) |
| 125 | + } |
| 126 | + |
| 127 | + for (const identifier of customProviders) { |
| 128 | + expect(isCustomProvider(identifier)).toBe(true) |
| 129 | + } |
| 130 | + |
| 131 | + for (const identifier of fauxProviders) { |
| 132 | + expect(isFauxProvider(identifier)).toBe(true) |
| 133 | + } |
| 134 | + |
| 135 | + expect(isDynamicProvider("unknown-provider")).toBe(false) |
| 136 | + expect(isLocalProvider("unknown-provider")).toBe(false) |
| 137 | + expect(isInternalProvider("unknown-provider")).toBe(false) |
| 138 | + expect(isCustomProvider("unknown-provider")).toBe(false) |
| 139 | + expect(isFauxProvider("unknown-provider")).toBe(false) |
| 140 | + |
| 141 | + const categoryRepresentatives = [ |
| 142 | + providerIdentifiers.openrouter, |
| 143 | + providerIdentifiers.ollama, |
| 144 | + providerIdentifiers.vscodeLm, |
| 145 | + providerIdentifiers.openai, |
| 146 | + providerIdentifiers.fakeAi, |
| 147 | + ] |
| 148 | + const categoryGuards = [ |
| 149 | + isDynamicProvider, |
| 150 | + isLocalProvider, |
| 151 | + isInternalProvider, |
| 152 | + isCustomProvider, |
| 153 | + isFauxProvider, |
| 154 | + ] |
| 155 | + |
| 156 | + for (const [guardIndex, guard] of categoryGuards.entries()) { |
| 157 | + for (const [identifierIndex, identifier] of categoryRepresentatives.entries()) { |
| 158 | + expect(guard(identifier)).toBe(guardIndex === identifierIndex) |
| 159 | + } |
| 160 | + } |
| 161 | + }) |
| 162 | + |
84 | 163 | it("keeps active and retired providers separate", () => { |
85 | 164 | const activeIdentifiers = new Set<string>(Object.values(providerIdentifiers)) |
86 | 165 | const retiredIdentifiers = Object.values(retiredProviderIdentifiers) |
|
0 commit comments