-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(setGlobalConfig): merge multiple levels deep
Merges config multiple levels deep. Also fixes docs and tests.
- Loading branch information
1 parent
314ca1f
commit b8cdd1d
Showing
3 changed files
with
45 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,30 @@ | ||
import testYf from "../../tests/testYf"; | ||
import options from "./options"; | ||
import setGlobalConfig from "./setGlobalConfig"; | ||
const yf = testYf({ setGlobalConfig }); | ||
|
||
describe("setGlobalConfig", () => { | ||
it("sets config options", () => { | ||
const optionsBackup = JSON.parse(JSON.stringify(options)); | ||
beforeEach(() => { | ||
yf._opts = JSON.parse(JSON.stringify(optionsBackup)); | ||
}); | ||
|
||
it("sets config options and passes validation", () => { | ||
const configOverrides = { queue: { concurrency: 10, timeout: 90 } }; | ||
yf.setGlobalConfig(configOverrides); | ||
expect(yf._opts.queue).toEqual(configOverrides.queue); | ||
expect(yf._opts).toEqual({ ...optionsBackup, ...configOverrides }); | ||
}); | ||
it("sets config options multiple levels deep", () => { | ||
const configOverrides = { queue: { concurrency: 10 } }; | ||
yf.setGlobalConfig(configOverrides); | ||
expect(yf._opts.queue).toEqual({ | ||
concurrency: 10, | ||
timeout: optionsBackup.queue.timeout, | ||
}); | ||
}); | ||
it("should throw on invalid config", () => { | ||
expect(() => yf.setGlobalConfig({ queue: { abc: "" } })).toThrow( | ||
/yahooFinance.setGlobalConfig called with invalid options\./ | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters