-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add vitest setup and knock client constructor tests
- Loading branch information
1 parent
2d4cc59
commit 2d6a3c1
Showing
4 changed files
with
734 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { describe, expect, test } from "vitest"; | ||
import { Knock } from "../src/knock"; | ||
|
||
describe("it can create a Knock client", () => { | ||
test("it sets configuration values", () => { | ||
const knock = new Knock("sk_test_12345", { | ||
host: "http://test.knock.app", | ||
}); | ||
|
||
expect(knock.key).toBe("sk_test_12345"); | ||
expect(knock.host).toBe("http://test.knock.app"); | ||
}); | ||
|
||
test("it defaults to reading the api key from env vars", () => { | ||
process.env.KNOCK_API_KEY = "sk_test_12345"; | ||
const knock = new Knock(); | ||
expect(knock.key).toBe("sk_test_12345"); | ||
delete process.env.KNOCK_API_KEY; | ||
}); | ||
|
||
test("it throws an error if no api key is provided", () => { | ||
expect(() => new Knock(undefined)).toThrowError(); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { defineConfig } from "vitest/config"; | ||
|
||
// Docs: https://vitest.dev/config/ | ||
export default defineConfig({ | ||
test: {}, | ||
}); |
Oops, something went wrong.