main
ts 37 lines 1.32 KB
Raw
1 /**
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8 import {parseConfigPragmaForTests, validateEnvironmentConfig} from '..';
9 import {defaultOptions} from '../Entrypoint';
10
11 describe('parseConfigPragmaForTests()', () => {
12 it('parses flags in various forms', () => {
13 const defaultConfig = validateEnvironmentConfig({});
14
15 // Validate defaults first to make sure that the parser is getting the value from the pragma,
16 // and not just missing it and getting the default value
17 expect(defaultConfig.enableForest).toBe(false);
18 expect(defaultConfig.validateNoSetStateInEffects).toBe(false);
19 expect(defaultConfig.validateNoSetStateInRender).toBe(true);
20
21 const config = parseConfigPragmaForTests(
22 '@enableForest @validateNoSetStateInEffects:true @validateNoSetStateInRender:false',
23 {compilationMode: defaultOptions.compilationMode},
24 );
25 expect(config).toEqual({
26 ...defaultOptions,
27 panicThreshold: 'all_errors',
28 environment: {
29 ...defaultOptions.environment,
30 enableForest: true,
31 validateNoSetStateInEffects: true,
32 validateNoSetStateInRender: false,
33 enableResetCacheOnSourceFileChanges: false,
34 },
35 });
36 });
37 });