1. ajwah-test
test lib for ajwah-store
ajwah-test
Package: ajwah-test
Created by: JUkhan
Last modified: Mon, 11 Apr 2022 13:10:42 GMT
Version: 1.1.2
License: MIT
Downloads: 5
Repository: https://github.com/JUkhan/Ajwah

Install

npm install ajwah-test
yarn add ajwah-test

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);
      },
    });
  });
});

Dependencies

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin