[test] Add test to make sure stringy enums are parsed correct
Meta internal config is going to be stringy, so let's add tests.
Sathya Gunasekaran committed
Nov 8, 2023 at 16:09 UTC
ec089d5454b9d711f15365616aebcc670cc414d6
1 file changed
+15
-1
compiler/packages/babel-plugin-react-forget/src/__tests__/envConfig-test.ts
+15
-1
@@ -5,7 +5,7 @@
5
* LICENSE file in the root directory of this source tree.
6
*/
7
8
-import { validateEnvironmentConfig } from "..";
8
+import { Effect, ValueKind, validateEnvironmentConfig } from "..";
9
10
describe("parseConfigPragma()", () => {
11
it("passing null throws", () => {
@@ -26,4 +26,18 @@ describe("parseConfigPragma()", () => {
26
);
27
}
28
});
29
+
30
+ it("can parse stringy enums", () => {
31
+ const stringyHook = {
32
+ effectKind: "freeze",
33
+ valueKind: "frozen",
34
+ };
35
+ const env = {
36
+ customHooks: new Map([["useFoo", stringyHook]]),
37
+ };
38
+ const validatedEnv = validateEnvironmentConfig(env as any);
39
+ const validatedHook = validatedEnv.customHooks.get("useFoo");
40
+ expect(validatedHook?.effectKind).toBe(Effect.Freeze);
41
+ expect(validatedHook?.valueKind).toBe(ValueKind.Frozen);
42
+ });
43
});