forked from StellarSplit/StellarSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstellar.service.spec.ts
More file actions
44 lines (36 loc) · 1.29 KB
/
Copy pathstellar.service.spec.ts
File metadata and controls
44 lines (36 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { ConfigService } from "@nestjs/config";
import { Networks } from "@stellar/stellar-sdk";
import { StellarService } from "./stellar.service";
describe("StellarService", () => {
const createConfigService = (passphrase?: string) =>
({
get: jest.fn((key: string) => {
if (key === "STELLAR_NETWORK_PASSPHRASE") {
return passphrase;
}
if (key === "STELLAR_HORIZON_URL") {
return "https://horizon-testnet.stellar.org";
}
if (key === "STELLAR_NETWORK") {
return "testnet";
}
return undefined;
}),
}) as unknown as ConfigService;
it("returns the configured Stellar network passphrase", () => {
const configService = createConfigService(
"Public Global Stellar Network ; September 2015",
);
const service = new StellarService(configService);
expect(service.getNetworkPassphrase()).toBe(
"Public Global Stellar Network ; September 2015",
);
expect((configService as any).get).toHaveBeenCalledWith(
"STELLAR_NETWORK_PASSPHRASE",
);
});
it("falls back to testnet when no passphrase is configured", () => {
const service = new StellarService(createConfigService(undefined));
expect(service.getNetworkPassphrase()).toBe(Networks.TESTNET);
});
});