ajwah-test
TypeScript icon, indicating that this package has built-in type declarations

1.1.2 • Public • Published

ajwah-test

>> npm i ajwah-test

testing counterState

import { ajwahTest } from "ajwah-test";
import { StateController } from "ajwah-store";

export class CounterState extends StateController<number> {
  constructor() {
    super({initialState:2});
  }
  increment() {
    this.update((state) => state + 1);
  }
  decrement() {
    this.update((state) => state - 1);
  }
}

describe("counterState", () => {
  let cs: CounterState;

  beforeEach(() => {
    cs = new CounterState();
  });

  it("initial state", async () => {
    await ajwahTest({
      build: () => cs.stream$,
      verify: (states) => {
        expect(states[0]).toBe(2);
      },
    });
  });

  it("increment", async () => {
    await ajwahTest({
      build: () => cs.stream$,
      act: () => {
        cs.increment();
      },
      skip: 1,
      verify: (states) => {
        expect(states[0]).toBe(3);
      },
    });
  });

  it("decrement", async () => {
    await ajwahTest({
      build: () => cs.stream$,
      act: () => {
        cs.decrement();
      },
      skip: 1,
      verify: (states) => {
        expect(states[0]).toBe(1);
      },
    });
  });
});

Package Sidebar

Install

npm i ajwah-test

Weekly Downloads

0

Version

1.1.2

License

MIT

Unpacked Size

129 kB

Total Files

26

Last publish

Collaborators

  • jukhan