Skip to content

Commit dbd15f3

Browse files
committed
test: add test for runtimeConfig
1 parent e79af3a commit dbd15f3

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

lib/lib-storage/src/index.spec.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,34 @@
1+
import fs from "node:fs";
12
import { describe, expect, test as it } from "vitest";
23

34
import * as Storage from "./index";
5+
import { runtimeConfig } from "./runtimeConfig";
6+
import { runtimeConfig as runtimeConfigBrowser } from "./runtimeConfig.browser";
7+
import { runtimeConfig as runtimeConfigNative } from "./runtimeConfig.native";
48

59
describe("Storage Packages", () => {
610
it("has Upload", () => {
711
expect(Storage.Upload).toBeDefined();
812
});
913
});
14+
15+
describe("runtimeConfig", () => {
16+
it("all environments have the same signature", () => {
17+
const configs = [runtimeConfig, runtimeConfigBrowser, runtimeConfigNative];
18+
19+
for (const config of configs) {
20+
expect(typeof config.lstatSync).toBe("function");
21+
expect(typeof config.isFileReadStream).toBe("function");
22+
}
23+
24+
const stream = fs.createReadStream(__filename);
25+
26+
expect(runtimeConfig.isFileReadStream(stream)).toBe(true);
27+
expect(runtimeConfigBrowser.isFileReadStream(stream)).toBe(false);
28+
expect(runtimeConfigNative.isFileReadStream(stream)).toBe(false);
29+
30+
expect(runtimeConfig.runtime).toBe("node");
31+
expect(runtimeConfigBrowser.runtime).toBe("browser");
32+
expect(runtimeConfigNative.runtime).toBe("react-native");
33+
});
34+
});

0 commit comments

Comments
 (0)