# @amazebot/rocket-sims

> Populate Rocket.Chat with mock users and messages for testing.

Latest version **0.1.1** (published 2019-04-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install @amazebot/rocket-sims
pnpm add @amazebot/rocket-sims
yarn add @amazebot/rocket-sims
bun add @amazebot/rocket-sims
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2019-04-21 |
| First published | 2018-12-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | > 8.0.0 |
| Dependencies | 5 |
| Unpacked size | 31.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Tim Kinnane |
| Maintainers | timkinnane |
| Keywords | rocket.chat, chat, chatops, messaging, CUI, typescript, testing |

## Links

- npm: https://www.npmjs.com/package/@amazebot/rocket-sims
- Repository: https://github.com/Amazebot/rocket-control
- Homepage: https://github.com/Amazebot/rocket-control/tree/master/packages/sims
- Issues: https://github.com/Amazebot/rocket-control/issues
- npm.io page: https://npm.io/package/@amazebot/rocket-sims

## Dependencies (5)

- [faker](https://npm.io/package/faker.md) ^4.1.0
- [@types/faker](https://npm.io/package/@types/faker.md) ^4.1.4
- [@amazebot/config](https://npm.io/package/@amazebot/config.md) ^0.1.1
- [@amazebot/logger](https://npm.io/package/@amazebot/logger.md) ^0.1.1
- [@amazebot/rocket-socket](https://npm.io/package/@amazebot/rocket-socket.md) ^0.1.1

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [vest](https://npm.io/package/vest.md) — 50.1K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2019-04-21
- 0.1.0 — 2019-02-27
- 0.0.1 — 2018-12-11

## README

[control]: https://github.com/Amazebot/rocket-control
[mentions]: https://github.com/Amazebot/rocket-control/tree/master/packages/examples/src/bot-mentions.ts

# 👩‍🎤 Rocket Sims
Populate Rocket.Chat with mock users and messages for testing.

---

### Usage

See the main [`rocket-control` README][control] for general configuration.

[This example script][mentions] uses `rocket-socket` and `rocket-sims` to create
a new bot user, connect to the general channel and stream all bot mentions to
the console.

#### `.lookup(username)`

Get user data for existing users.

```ts
import { user } from '@amazebot/rocket-sims'
user.lookup('admin')
  .then((data) => console.log(data))
```

#### `.create(user)`

Register new user from given attributes and defaults.

```ts
import { user } from '@amazebot/rocket-sims'
async function registerSims {
  const u1 = await user.create({ username: 'sim1' })
  const u2 = await user.create({ username: 'sim2' })
}
```

You muse include `username` OR `name`. Other attributes and defaults are:

```
password: string // default: random
email: string // default: null account at test.smtp.org
roles: string[] // default: ['user']
joinDefaultChannels: boolean // default: false
requirePasswordChange: boolean // default: false
sendWelcomeEmail: boolean // default: false
verified: boolean // default: true
```

You can also include any key/value pairs for custom user fields.

Create methods returns a user *record* containing:
- `.id` the created user ID
- `.account` contains details from creation (params merged with defaults)
- `.login()` logs in the user via websocket (DDP / Realtime API)
- `.delete()` deletes this user from server

Login returns a websocket instance for the logged in user to make subsequent
server method calls and subscriptions. e.g:

```ts
u1 = await user.create({ username: 'sim1' })
ws1 = await u1.login()
await ws1.call('joinRoom', 'general')
```

#### `.random()`

Creates a user with a random name. Returns the same as `.create`

#### `.records`

A collection of created users assigned to their ID.

#### `.deleteAll()`

Deletes all users created in the current session.

---
_Source: https://npm.io/package/@amazebot/rocket-sims · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
