Skip to content

Commit c492f4d

Browse files
committed
Export error classes and refactor tests to use exposed functions
By utilising functions exposed via `mod.ts` as much as possible in tests, errors related to imports can be caught early
1 parent 1ad75a8 commit c492f4d

5 files changed

Lines changed: 15 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ and this project adheres to
1010

1111
### Added
1212

13+
- Export error classes.
14+
1315
### Changed
1416

1517
### Fixed

mod.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
export type { Config } from "./src/config.ts";
22
export { config } from "./src/config.ts";
33

4+
export { InvalidTimeoutError, MissingApiKeyError } from "./src/errors.ts";
5+
46
export type {
57
AccountApiParameters,
68
AccountInformation,

tests/engines/google_test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ import {
2222
assertStringIncludes,
2323
} from "https://deno.land/std@0.170.0/testing/asserts.ts";
2424
import { _internals } from "../../src/utils.ts";
25-
import { MissingApiKeyError } from "../../src/errors.ts";
2625
import {
26+
config,
2727
getHtml,
2828
getHtmlBySearchId,
2929
getJson,
3030
getJsonBySearchId,
31-
} from "../../src/serpapi.ts";
32-
import { config } from "../../src/config.ts";
31+
MissingApiKeyError,
32+
} from "../../mod.ts";
3333

3434
loadSync({ export: true });
3535
const SERPAPI_TEST_KEY = Deno.env.get("SERPAPI_TEST_KEY") ?? "";

tests/serpapi_test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@ import {
1212
assertRejects,
1313
} from "https://deno.land/std@0.170.0/testing/asserts.ts";
1414
import { Stub, stub } from "https://deno.land/std@0.170.0/testing/mock.ts";
15-
import { InvalidTimeoutError, MissingApiKeyError } from "../src/errors.ts";
16-
import { getAccount, getLocations } from "../src/serpapi.ts";
1715
import { _internals } from "../src/utils.ts";
18-
import { config } from "../src/config.ts";
16+
import {
17+
config,
18+
getAccount,
19+
getLocations,
20+
InvalidTimeoutError,
21+
MissingApiKeyError,
22+
} from "../mod.ts";
1923

2024
loadSync({ export: true });
2125
const SERPAPI_TEST_KEY = Deno.env.get("SERPAPI_TEST_KEY") ?? "";

tests/validators_test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import {
88
assertThrows,
99
} from "https://deno.land/std@0.170.0/testing/asserts.ts";
1010
import { validateApiKey, validateTimeout } from "../src/validators.ts";
11-
import { config } from "../src/config.ts";
12-
import { InvalidTimeoutError, MissingApiKeyError } from "../src/errors.ts";
11+
import { config, InvalidTimeoutError, MissingApiKeyError } from "../mod.ts";
1312

1413
describe("validateApiKey", () => {
1514
afterEach(() => {

0 commit comments

Comments
 (0)