Skip to content

Commit fd8d987

Browse files
committed
test: doNotLoadConfig + injectValidationFunction: false
1 parent 7d8eb6f commit fd8d987

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

app-config-esbuild/src/__snapshots__/index.test.ts.snap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,8 @@ exports[`loads with doNotLoadConfig 1`] = `
1919
"(()=>{var v=(typeof window==\\"undefined\\"?globalThis:window)||{},i=v._appConfig;if(typeof i==\\"undefined\\")throw new Error(\\"Config is not loaded in _appConfig\\");function m(){let s={};return function(p){\\"use strict\\";p.exports=n,p.exports.default=n;var P={type:\\"object\\",additionalProperties:!1,properties:{foo:{type:\\"string\\"}},$schema:\\"http://json-schema.org/draft-07/schema#\\"};function n(o,t){\\"use strict\\";if(t)var r=t.dataPath,h=t.parentData,g=t.parentDataProperty,y=t.rootData;else var r=\\"\\",h=void 0,g=void 0,y=o;var e=null,a=0;if(o&&typeof o==\\"object\\"&&!Array.isArray(o)){for(var f in o)if(f!==\\"foo\\"){var d={keyword:\\"additionalProperties\\",dataPath:r,schemaPath:\\"#/additionalProperties\\",params:{additionalProperty:f},message:\\"should NOT have additional properties\\"};e===null?e=[d]:e.push(d),a++}if(o.foo!==void 0&&typeof o.foo!=\\"string\\"){var l={keyword:\\"type\\",dataPath:r+\\"/foo\\",schemaPath:\\"#/properties/foo/type\\",params:{type:\\"string\\"},message:\\"should be string\\"};e===null?e=[l]:e.push(l),a++}}else{var u={keyword:\\"type\\",dataPath:r,schemaPath:\\"#/type\\",params:{type:\\"object\\"},message:\\"should be object\\"};e===null?e=[u]:e.push(u),a++}return n.errors=e,a===0}}(s),s.exports}var c=m();c(i);})();
2020
"
2121
`;
22+
23+
exports[`loads with doNotLoadConfig and no validation function 1`] = `
24+
"(()=>{var o=(typeof window==\\"undefined\\"?globalThis:window)||{},n=o._appConfig;if(typeof n==\\"undefined\\")throw new Error(\\"Config is not loaded in _appConfig\\");console.log(n);})();
25+
"
26+
`;

app-config-esbuild/src/index.test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,37 @@ it('loads with doNotLoadConfig', () =>
151151
expect(res.outputFiles[0].text).toMatchSnapshot();
152152
},
153153
));
154+
155+
it('loads with doNotLoadConfig and no validation function', () =>
156+
withTempFiles(
157+
{
158+
'.app-config.schema.yml': `
159+
type: object
160+
additionalProperties: false
161+
properties:
162+
foo: { type: string }
163+
`,
164+
'a.js': `
165+
import { config } from '@app-config/main';
166+
167+
console.log(config);
168+
`,
169+
},
170+
async (inDir) => {
171+
const res = await build({
172+
entryPoints: [inDir('a.js')],
173+
plugins: [
174+
createPlugin({
175+
schemaLoadingOptions: { directory: inDir('.') },
176+
doNotLoadConfig: true,
177+
injectValidationFunction: false,
178+
}),
179+
],
180+
bundle: true,
181+
minify: true,
182+
write: false,
183+
});
184+
185+
expect(res.outputFiles[0].text).toMatchSnapshot();
186+
},
187+
));

0 commit comments

Comments
 (0)