# act-master-test-utils

> act-master test-utils

Latest version **0.0.1** (published 2020-11-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install act-master-test-utils
pnpm add act-master-test-utils
yarn add act-master-test-utils
bun add act-master-test-utils
```

## Health

**Score 40/100 (D)** — status: abandoned.

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

Warnings: low downloads; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2020-11-05 |
| First published | 2020-11-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 26.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | avil13 |
| Maintainers | avil13 |

## Links

- npm: https://www.npmjs.com/package/act-master-test-utils
- Repository: https://github.com/avil13/vue-act-master
- Homepage: https://github.com/avil13/vue-act-master#readme
- Issues: https://github.com/avil13/vue-act-master/issues
- npm.io page: https://npm.io/package/act-master-test-utils

## Recent versions

- 0.0.1 (latest) — 2020-11-05

## README

# Act-Master-test-utils

`ActTest` - is a class that helps write tests for `act-master`.

ActTest - is a singleton class with static methods.

To write tests, use the method `ActTest.getInstance(options?: ActMasterOptions)`.

It creates an instance of the `act-master` class, which can be easily used afterwards.

## Example:


###### default configuration for examples

```ts
// Basic part, same for all examples

import { ActTest } from 'act-master-test-utils';

const $act = ActTest.getInstance();

beforeEach(() => {
  ActTest.resetAll();
});
// ...
```

```ts
// ... base settings

it('Example result', async () => {
  const action: ActMasterAction = {
    name: 'SomeName',
    exec() {
      return 42;
    }
  }

  $act.addActions([action]);

  await $act.exec('SomeName');

  expect(ActTest.getLastResult()).toBe(42);
});
```

---

You can also call some event and check your subscription.

```ts
// ... base settings

it('Example check subscription', async () => {
  const action: ActMasterAction = {
    name: 'SomeName',
    exec() {
      return 42;
    }
  }

  $act.addActions([action]);

  const mockFn = jest.fn();

  $act.subscribe('SomeName', mockFn);

  await ActTest.exec('SomeName');

  expect(mockFn).toBeCalledTimes(1);
});
```


## List of available methods

| Method Name  |  Description
|---	|---	|
| getInstance      | Returns the ActMaster instance
| resetAll         | Resets the ActMaster settings
| getLastResult    | Returns the last value
| addActions       | Adds actions
| exec             | Execute action
| subscribe        | Subscribes to action
| entityCount      | Returns the number of entities ('actions' \| 'waiters' \| 'listeners' \| 'di') *
| removeSingleton  | Removes singleton ActMaster *


> `*` -Use if you know what it's for

---
_Source: https://npm.io/package/act-master-test-utils · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
