Skip to content

Commit 8dfe390

Browse files
committed
fix(modules): finish up { validateOptions: false } module opt
Relates to #892, still need to add some docs somewhere
1 parent 126851b commit 8dfe390

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

src/lib/moduleCommon.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
// import type ModuleExec from "./moduleExec.js";
22

33
export interface ModuleOptions {
4+
/** If false, lib won't validaet and will leave that to Yahoo */
5+
validateOptions?: boolean;
6+
/** If false, will pass back unvalidated / untyped result from Yahoo */
47
validateResult?: boolean;
8+
/** Filename to use for cached result */
59
devel?: boolean | string;
6-
fetchOptions?: object;
10+
/** Any options to pass to fetch() just for this request. */
11+
fetchOptions?: Parameters<typeof fetch>[1];
712
}
813

914
export interface ModuleOptionsWithValidateFalse extends ModuleOptions {

src/lib/moduleExec.test.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,12 @@ describe("moduleExec", () => {
5454
await expect(rwo({ invalid: true })).rejects.toThrow(InvalidOptionsError);
5555
});
5656

57-
/*
58-
XXX TODO
59-
* with new yf() option, and with moduleoptions
60-
it("throws InvalidOptions on invalid options with validateOptions = false", async () => {
61-
const rwo = (options: any) => yf.search("symbol", options);
62-
await expect(rwo({ invalid: true })).rejects.toThrow(InvalidOptionsError);
57+
it("does not throw InvalidOptions on invalid options with validateOptions = false", async () => {
58+
// deno-lint-ignore no-explicit-any
59+
const rwo = (options: any) =>
60+
yf.search("symbol", options, { validateOptions: false });
61+
await expect(rwo({ invalid: true })).resolves.toBeDefined();
6362
});
64-
*/
6563

6664
it("accepts empty queryOptions", async () => {
6765
await expect(

src/lib/moduleExec.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import validateAndCoerceTypes, {
2020
} from "./validateAndCoerceTypes.ts";
2121
import csv2json from "./csv2json.ts";
2222
import type { JSONSchema } from "./validate/index.ts";
23+
import type { ModuleOptions } from "./moduleCommon.ts";
2324

2425
// The consuming module itself will have a stricter return type.
2526
// deno-lint-ignore no-explicit-any
@@ -107,14 +108,7 @@ interface ModuleExecOptions {
107108
transformWith?: TransformFunc;
108109
};
109110

110-
moduleOptions?: {
111-
/** Allow validation failures to pass if false; */
112-
validateOptions?: boolean;
113-
/** Allow validation failures to pass if false; */
114-
validateResult?: boolean;
115-
/** Any options to pass to fetch() just for this request. */
116-
fetchOptions?: Parameters<typeof fetch>[1];
117-
};
111+
moduleOptions?: ModuleOptions;
118112
}
119113

120114
// deno-lint-ignore no-explicit-any

0 commit comments

Comments
 (0)