Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Add unit tests for @unkey/api #474

Merged
merged 5 commits into from Dec 8, 2023

Conversation

KartikSoneji
Copy link
Contributor

Type of change

  • πŸ› Bug fix
  • 🌟 New feature
  • πŸ”¨ Breaking change
  • πŸ“– Refactoring / dependency upgrade / documentation

Description

Add unit tests for @unkey/client

A picture tells a thousand words (if any)

Before this PR

<no tests>

After this PR

> bun test:coverage
$ bun test --coverage
bun test v1.0.11 (f7f6233e)

test/client.test.ts:
βœ“ Unkey client > default config [0.34ms]
βœ“ Unkey client > respects config args [0.07ms]
βœ“ Unkey client > throws for invalid rootKey [0.24ms]
βœ“ Unkey client > retry.attempts works [15.09ms]
βœ“ Unkey client > calls succeed if fetch fails some retries [4.32ms]
βœ“ Unkey client > returns an error if fetch throws [11.00ms]
βœ“ Unkey client > retry.backoff is called as expected on each failure [6.77ms]
βœ“ snapshot api calls > client.keys > create [1.05ms]
βœ“ snapshot api calls > client.keys > update [0.49ms]
βœ“ snapshot api calls > client.keys > verify [1.59ms]
βœ“ snapshot api calls > client.keys > revoke [1.49ms]
βœ“ snapshot api calls > client.apis > client._internal > createRootKey [0.62ms]
βœ“ snapshot api calls > client.apis > client._internal > deleteRootKey [0.44ms]
βœ“ snapshot api calls > client.apis > update [0.38ms]
βœ“ snapshot api calls > client.apis > remove [0.42ms]
βœ“ snapshot api calls > client.apis > get [0.24ms]
βœ“ snapshot api calls > client.apis > listKeys [0.61ms]

test/mock-fetch.test.ts:

test/verify.test.ts:
βœ“ verifyKey() function > accepts plain string [0.30ms]
βœ“ verifyKey() function > accepts { key, apiId } [0.20ms]
---------------|---------|---------|-------------------
File           | % Funcs | % Lines | Uncovered Line #s
---------------|---------|---------|-------------------
All files      |   99.14 |  100.00 |
 src/client.ts |   96.55 |  100.00 |
 src/errors.ts |  100.00 |  100.00 |
 src/index.ts  |  100.00 |  100.00 |
 src/verify.ts |  100.00 |  100.00 |
---------------|---------|---------|-------------------

 19 pass
 0 fail
 81 expect() calls
Ran 19 tests across 3 files. [178.00ms]

Copy link

changeset-bot bot commented Nov 13, 2023

⚠️ No Changeset found

Latest commit: d4d4742

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Nov 13, 2023

@KartikSoneji is attempting to deploy a commit to the Unkey Team on Vercel.

A member of the Team first needs to authorize it.

@KartikSoneji KartikSoneji marked this pull request as draft November 13, 2023 16:33
@KartikSoneji KartikSoneji force-pushed the tests/unkey-client branch 2 times, most recently from bd21735 to d2f7b1c Compare November 13, 2023 17:03
@CLAassistant
Copy link

CLAassistant commented Nov 17, 2023

CLA assistant check
All committers have signed the CLA.

@KartikSoneji KartikSoneji changed the title tests: Add unit tests for @unkey/client tests: Add unit tests for @unkey/api Nov 22, 2023
Copy link
Contributor

github-actions bot commented Nov 22, 2023

Thank you for following the naming conventions for pull request titles! πŸ™

@KartikSoneji KartikSoneji changed the title tests: Add unit tests for @unkey/api test: Add unit tests for @unkey/api Nov 22, 2023
@KartikSoneji KartikSoneji marked this pull request as ready for review November 23, 2023 09:41
Copy link

vercel bot commented Nov 23, 2023

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Comments Updated (UTC)
unkey βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Dec 8, 2023 7:47am
workflows βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Dec 8, 2023 7:47am

packages/api/test/client.test.ts Outdated Show resolved Hide resolved
packages/api/test/client.test.ts Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants