Skip to content

Commit

Permalink
test: use toEqual
Browse files Browse the repository at this point in the history
  • Loading branch information
johannschopplich committed Nov 1, 2023
1 parent 31f3932 commit 886ad20
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022-2023 Johann Schopplich
Copyright (c) 2022-PRESENT Johann Schopplich

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

> Minimal, type-safe REST client using JS proxies.
> 鈩癸笍 If you like this package, [upvote this feature to be part of `unjs/ofetch`](https://github.com/unjs/ofetch/pull/69) Much appreciated.
> [!NOTE]
> Thanks to everyone who has [upvoted this feature to be part of `unjs/ofetch`](https://github.com/unjs/ofetch/pull/69)! This library will be part of the upcoming [`api-party`](https://github.com/unjs/api-party) package.
## Features

Expand Down Expand Up @@ -128,4 +129,4 @@ const response = await api.users.get({

## License

[MIT](./LICENSE) License 漏 2022-2023 [Johann Schopplich](https://github.com/johannschopplich)
[MIT](./LICENSE) License 漏 2022-PRESENT [Johann Schopplich](https://github.com/johannschopplich)
24 changes: 12 additions & 12 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,35 +42,35 @@ describe('unrested', () => {

it('GET request', async () => {
const response = await client.foo.get()
expect(response).to.deep.equal({ foo: 'bar' })
expect(response).toEqual({ foo: 'bar' })
})

it('POST request', async () => {
const response = await client.bar.post({ foo: 'bar' })
expect(response.body).to.deep.equal({ foo: 'bar' })
expect(response.method).to.equal('POST')
expect(response.body).toEqual({ foo: 'bar' })
expect(response.method).toEqual('POST')
})

it('PUT request', async () => {
const response = await client.bar.put({ foo: 'bar' })
expect(response.body).to.deep.equal({ foo: 'bar' })
expect(response.method).to.equal('PUT')
expect(response.body).toEqual({ foo: 'bar' })
expect(response.method).toEqual('PUT')
})

it('DELETE request', async () => {
const response = await client.bar.delete()
expect(response.method).to.equal('DELETE')
expect(response.method).toEqual('DELETE')
})

it('PATCH request', async () => {
const response = await client.bar.patch({ foo: 'bar' })
expect(response.body).to.deep.equal({ foo: 'bar' })
expect(response.method).to.equal('PATCH')
expect(response.body).toEqual({ foo: 'bar' })
expect(response.method).toEqual('PATCH')
})

it('query parameter', async () => {
const response = await client.params.get({ test: 'true' })
expect(response).to.deep.equal({ test: 'true' })
expect(response).toEqual({ test: 'true' })
})

it('default options', async () => {
Expand All @@ -95,19 +95,19 @@ describe('unrested', () => {

it('bracket syntax for path segment', async () => {
const response = await client.foo['1'].get<FooResponse>()
expect(response).to.deep.equal({ foo: '1' })
expect(response).toEqual({ foo: '1' })
assertType<{ foo: string }>(response)
})

it('chain syntax for path segment', async () => {
const response = await client.foo(1).get<FooResponse>()
expect(response).to.deep.equal({ foo: '1' })
expect(response).toEqual({ foo: '1' })
assertType<{ foo: string }>(response)
})

it('multiple path segments', async () => {
const response = await client('foo', '1').get<FooResponse>()
expect(response).to.deep.equal({ foo: '1' })
expect(response).toEqual({ foo: '1' })
assertType<{ foo: string }>(response)
})

Expand Down

0 comments on commit 886ad20

Please sign in to comment.