-
-
Notifications
You must be signed in to change notification settings - Fork 754
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(guides): Review getting started and CLI guide (#3028)
- Loading branch information
Showing
20 changed files
with
310 additions
and
479 deletions.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
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
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
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
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 |
---|---|---|
@@ -1,3 +1,40 @@ | ||
# Client test | ||
|
||
> This page is currently a work in progress | ||
The `client.test` file contains end-to-end integration tests for the [generated client](./client.md). | ||
|
||
## Authentication | ||
|
||
If you selected a local strategy, `src/client.ts` will be updated with a client side integration test that looks similar to this: | ||
|
||
```ts | ||
it('creates and authenticates a user with email and password', async () => { | ||
const userData: userData = { | ||
email: 'someone@example.com', | ||
password: 'supersecret' | ||
} | ||
|
||
await client.service('users').create(userData) | ||
|
||
const { user, accessToken } = await client.authenticate({ | ||
strategy: 'local', | ||
...userData | ||
}) | ||
|
||
assert.ok(accessToken, 'Created access token for user') | ||
assert.ok(user, 'Includes user in authentication data') | ||
assert.strictEqual(user.password, undefined, 'Password is hidden to clients') | ||
|
||
await client.logout() | ||
|
||
// Remove the test user on the server | ||
await app.service('users').remove(user.id) | ||
}) | ||
``` | ||
|
||
This test will create a new user with the generated client, log in, verify a user was returned and log out again. To keep the test self-contained it will then remove the test user on the server | ||
|
||
<BlockQuote type="tip"> | ||
|
||
Note that you can use `client` for client side interactions and the server side [application](./app.md#application) `app` object for server side calls in the same file. For example, if the user required an email verification but you don't want to test sending out emails you can call something like `app.service('users').patch(user.id, { isVerified: true })` to enable the new user on the server. | ||
|
||
</BlockQuote> |
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
Oops, something went wrong.