|
| 1 | +// Jest Snapshot v1, https://goo.gl/fbAQLP |
| 2 | + |
| 3 | +exports[`generateModuleText creates config module 1`] = ` |
| 4 | +" |
| 5 | + const config = {\\"foo\\":\\"bar\\"}; |
| 6 | +
|
| 7 | + export { config }; |
| 8 | + export default config; |
| 9 | + |
| 10 | + export function currentEnvironment() { |
| 11 | + return \\"test\\"; |
| 12 | + } |
| 13 | + " |
| 14 | +`; |
| 15 | + |
| 16 | +exports[`generateModuleText creates config module with esm validation function 1`] = ` |
| 17 | +" |
| 18 | + const configValue = {\\"foo\\":\\"bar\\"}; |
| 19 | +
|
| 20 | + const globalNamespace = (typeof window === 'undefined' ? globalThis : window) || {}; |
| 21 | +
|
| 22 | + // if the global was already defined, use it |
| 23 | + const config = (globalNamespace._appConfig || configValue); |
| 24 | +
|
| 25 | + // if the global is frozen then it was set by electron and we can't change it, but we'll set it if we can |
| 26 | + if ( |
| 27 | + typeof globalNamespace._appConfig === 'undefined' || |
| 28 | + !Object.isFrozen(globalNamespace._appConfig) |
| 29 | + ) { |
| 30 | + globalNamespace._appConfig = config; |
| 31 | + } |
| 32 | +
|
| 33 | + export { config }; |
| 34 | + export default config; |
| 35 | + |
| 36 | + const foo = 'bar'; |
| 37 | +
|
| 38 | + |
| 39 | + function genValidateConfig(){ |
| 40 | + const validateConfigModule = {}; |
| 41 | + (function(module){import foo from \\"bar\\";})(validateConfigModule); |
| 42 | + return validateConfigModule.exports; |
| 43 | + } |
| 44 | +
|
| 45 | + |
| 46 | + export const validateConfig = /*#__PURE__*/ genValidateConfig(); |
| 47 | + |
| 48 | + export function currentEnvironment() { |
| 49 | + return \\"test\\"; |
| 50 | + } |
| 51 | + " |
| 52 | +`; |
| 53 | + |
| 54 | +exports[`generateModuleText creates config module with global namespace 1`] = ` |
| 55 | +" |
| 56 | + const configValue = {\\"foo\\":\\"bar\\"}; |
| 57 | +
|
| 58 | + const globalNamespace = (typeof window === 'undefined' ? globalThis : window) || {}; |
| 59 | +
|
| 60 | + // if the global was already defined, use it |
| 61 | + const config = (globalNamespace._appConfig || configValue); |
| 62 | +
|
| 63 | + // if the global is frozen then it was set by electron and we can't change it, but we'll set it if we can |
| 64 | + if ( |
| 65 | + typeof globalNamespace._appConfig === 'undefined' || |
| 66 | + !Object.isFrozen(globalNamespace._appConfig) |
| 67 | + ) { |
| 68 | + globalNamespace._appConfig = config; |
| 69 | + } |
| 70 | +
|
| 71 | + export { config }; |
| 72 | + export default config; |
| 73 | + |
| 74 | + export function currentEnvironment() { |
| 75 | + return \\"test\\"; |
| 76 | + } |
| 77 | + " |
| 78 | +`; |
| 79 | + |
| 80 | +exports[`generateModuleText creates config module with validation function 1`] = ` |
| 81 | +" |
| 82 | + const configValue = {\\"foo\\":\\"bar\\"}; |
| 83 | +
|
| 84 | + const globalNamespace = (typeof window === 'undefined' ? globalThis : window) || {}; |
| 85 | +
|
| 86 | + // if the global was already defined, use it |
| 87 | + const config = (globalNamespace._appConfig || configValue); |
| 88 | +
|
| 89 | + // if the global is frozen then it was set by electron and we can't change it, but we'll set it if we can |
| 90 | + if ( |
| 91 | + typeof globalNamespace._appConfig === 'undefined' || |
| 92 | + !Object.isFrozen(globalNamespace._appConfig) |
| 93 | + ) { |
| 94 | + globalNamespace._appConfig = config; |
| 95 | + } |
| 96 | +
|
| 97 | + export { config }; |
| 98 | + export default config; |
| 99 | + |
| 100 | + |
| 101 | + function genValidateConfig(){ |
| 102 | + const validateConfigModule = {}; |
| 103 | + (function(module){ |
| 104 | + const foo = 'bar'; |
| 105 | + })(validateConfigModule); |
| 106 | + return validateConfigModule.exports; |
| 107 | + } |
| 108 | +
|
| 109 | + |
| 110 | + export const validateConfig = /*#__PURE__*/ genValidateConfig(); |
| 111 | + |
| 112 | + export function currentEnvironment() { |
| 113 | + return \\"test\\"; |
| 114 | + } |
| 115 | + " |
| 116 | +`; |
0 commit comments