Skip to content

Commit d27cebd

Browse files
test: cover env to descriptor selection for both paseo and summit
The consumer tests (connection / registry / bulletinAuthContext) only exercise whichever env is the active DEFAULT_ENV, so with paseo as the default the summit arms of the descriptor selectors never ran. Add a direct test for descriptors.ts that asserts both branches explicitly, independent of ACTIVE_TESTNET_ENV, so summit selection is tested today and the one-line network switch stays a no-surprise flip.
1 parent 959d7a9 commit d27cebd

1 file changed

Lines changed: 93 additions & 0 deletions

File tree

src/utils/descriptors.test.ts

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
// Copyright (C) Parity Technologies (UK) Ltd.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
// Direct coverage of the env → descriptor selectors. The consumer tests
17+
// (connection / registry / bulletinAuthContext) only exercise whichever env is
18+
// the active `DEFAULT_ENV`, so when the network switch is on paseo the summit
19+
// arms here would otherwise never run. These cases assert BOTH branches
20+
// explicitly, independent of `ACTIVE_TESTNET_ENV`, so the summit selection is
21+
// genuinely tested today and the one-line switch stays a no-surprise flip.
22+
23+
import { describe, expect, it, vi } from "vitest";
24+
25+
// Identity-tagged stand-ins so the assertions can prove WHICH descriptor object
26+
// each selector returns without importing the real (heavy) descriptors.
27+
vi.mock("@parity/product-sdk-descriptors/paseo-asset-hub", () => ({
28+
paseo_asset_hub: { genesis: "0xpaseo-asset" },
29+
}));
30+
vi.mock("@parity/product-sdk-descriptors/paseo-bulletin", () => ({
31+
paseo_bulletin: { genesis: "0xpaseo-bulletin" },
32+
}));
33+
vi.mock("@parity/product-sdk-descriptors/paseo-individuality", () => ({
34+
paseo_individuality: { genesis: "0xpaseo-people" },
35+
}));
36+
vi.mock("@parity/product-sdk-descriptors/summit-asset-hub", () => ({
37+
summit_asset_hub: { genesis: "0xsummit-asset" },
38+
}));
39+
vi.mock("@parity/product-sdk-descriptors/summit-bulletin", () => ({
40+
summit_bulletin: { genesis: "0xsummit-bulletin" },
41+
}));
42+
vi.mock("@parity/product-sdk-descriptors/summit-individuality", () => ({
43+
summit_individuality: { genesis: "0xsummit-people" },
44+
}));
45+
46+
import { paseo_asset_hub } from "@parity/product-sdk-descriptors/paseo-asset-hub";
47+
import { paseo_bulletin } from "@parity/product-sdk-descriptors/paseo-bulletin";
48+
import { paseo_individuality } from "@parity/product-sdk-descriptors/paseo-individuality";
49+
import { summit_asset_hub } from "@parity/product-sdk-descriptors/summit-asset-hub";
50+
import { summit_bulletin } from "@parity/product-sdk-descriptors/summit-bulletin";
51+
import { summit_individuality } from "@parity/product-sdk-descriptors/summit-individuality";
52+
import {
53+
getAssetHubDescriptor,
54+
getBulletinDescriptor,
55+
getIndividualityDescriptor,
56+
} from "./descriptors.js";
57+
58+
describe("getAssetHubDescriptor", () => {
59+
it("returns the summit descriptor for summit", () => {
60+
expect(getAssetHubDescriptor("summit")).toBe(summit_asset_hub);
61+
});
62+
63+
it("returns the paseo descriptor for paseo-next-v2", () => {
64+
expect(getAssetHubDescriptor("paseo-next-v2")).toBe(paseo_asset_hub);
65+
});
66+
67+
it("falls back to paseo for any non-summit env (summit is the only divergent one)", () => {
68+
expect(getAssetHubDescriptor("polkadot")).toBe(paseo_asset_hub);
69+
expect(getAssetHubDescriptor(undefined)).toBe(paseo_asset_hub);
70+
});
71+
});
72+
73+
describe("getBulletinDescriptor", () => {
74+
it("returns the summit descriptor for summit", () => {
75+
expect(getBulletinDescriptor("summit")).toBe(summit_bulletin);
76+
});
77+
78+
it("returns the paseo descriptor otherwise", () => {
79+
expect(getBulletinDescriptor("paseo-next-v2")).toBe(paseo_bulletin);
80+
expect(getBulletinDescriptor(undefined)).toBe(paseo_bulletin);
81+
});
82+
});
83+
84+
describe("getIndividualityDescriptor", () => {
85+
it("returns the summit descriptor for summit", () => {
86+
expect(getIndividualityDescriptor("summit")).toBe(summit_individuality);
87+
});
88+
89+
it("returns the paseo descriptor otherwise", () => {
90+
expect(getIndividualityDescriptor("paseo-next-v2")).toBe(paseo_individuality);
91+
expect(getIndividualityDescriptor(undefined)).toBe(paseo_individuality);
92+
});
93+
});

0 commit comments

Comments
 (0)