-
Notifications
You must be signed in to change notification settings - Fork 51.1k
Expand file tree
/
Copy pathparseConfigPragma-test.ts
More file actions
39 lines (35 loc) · 1.43 KB
/
parseConfigPragma-test.ts
File metadata and controls
39 lines (35 loc) · 1.43 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
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import {parseConfigPragmaForTests, validateEnvironmentConfig} from '..';
import {defaultOptions} from '../Entrypoint';
describe('parseConfigPragmaForTests()', () => {
it('parses flags in various forms', () => {
const defaultConfig = validateEnvironmentConfig({});
// Validate defaults first to make sure that the parser is getting the value from the pragma,
// and not just missing it and getting the default value
expect(defaultOptions.enableEmitTraceTape).toBe(false);
expect(defaultConfig.enableForest).toBe(false);
expect(defaultConfig.validateNoSetStateInEffects).toBe(false);
expect(defaultConfig.validateNoSetStateInRender).toBe(true);
const config = parseConfigPragmaForTests(
'@enableForest @enableEmitTraceTape @validateNoSetStateInEffects:true @validateNoSetStateInRender:false',
{compilationMode: defaultOptions.compilationMode},
);
expect(config).toEqual({
...defaultOptions,
enableEmitTraceTape: true,
panicThreshold: 'all_errors',
environment: {
...defaultOptions.environment,
enableForest: true,
validateNoSetStateInEffects: true,
validateNoSetStateInRender: false,
enableResetCacheOnSourceFileChanges: false,
},
});
});
});