Skip to content

Commit

Permalink
coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
gadicc committed Apr 11, 2021
1 parent 2f3e9b1 commit f93f281
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
19 changes: 19 additions & 0 deletions src/lib/yahooFinanceFetch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,25 @@ describe("yahooFinanceFetch", () => {
moduleOpts = { queue: { _queue: new Queue() } };
});

it("Queue takes options in constructor", () => {
const queue = new Queue({ concurrency: 5 });
expect(queue.concurrency).toBe(5);
});

it("yahooFinanceFetch branch check for alternate queue", () => {
const promises = [
yahooFinanceFetch("", {}),
yahooFinanceFetch("", {}, {}),
yahooFinanceFetch("", {}, { queue: {} }),
];

env.fetch.fetches[0].resolveWith({ ok: true });
env.fetch.fetches[1].resolveWith({ ok: true });
env.fetch.fetches[2].resolveWith({ ok: true });

return Promise.all(promises);
});

it("assert defualts to {} for empty queue opts", () => {
moduleOpts.queue.concurrency = 1;
const opts = { ..._opts };
Expand Down
4 changes: 2 additions & 2 deletions src/lib/yahooFinanceFetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ async function yahooFinanceFetch(
"yahooFinanceFetch called without this._env set"
);

const queue = moduleOpts?.queue?._queue || _queue;
assertQueueOptions(queue, moduleOpts.queue || this._opts.queue || {});
const queue = moduleOpts.queue?._queue || _queue;
assertQueueOptions(queue, { ...this._opts.queue, ...moduleOpts.queue });

const { URLSearchParams, fetch, fetchDevel } = this._env;

Expand Down

0 comments on commit f93f281

Please sign in to comment.