Skip to content

Commit

Permalink
breaking change: make no patches default, rename patch adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
EskiMojo14 committed May 29, 2024
1 parent 5b224e3 commit f258158
Show file tree
Hide file tree
Showing 5 changed files with 177 additions and 187 deletions.
14 changes: 7 additions & 7 deletions src/creator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import { describe, expect, it } from "vitest";
import { historyMethodsCreator, undoableCreatorsCreator } from "./creator";
import type { HistoryState } from "./redux";
import { createHistoryAdapter, createNoPatchHistoryAdapter } from "./redux";
import { createHistoryAdapter, createPatchHistoryAdapter } from "./redux";

interface Book {
title: string;
Expand Down Expand Up @@ -95,9 +95,9 @@ describe("Slice creators", () => {

store.dispatch(undone());

expect(selectLastBook(store.getState())).toBe(book2);
expect(selectLastBook(store.getState())).toBe(book1);

store.dispatch(jumped(-1));
store.dispatch(jumped(1));

expect(selectLastBook(store.getState())).toStrictEqual(book2);

Expand Down Expand Up @@ -204,9 +204,9 @@ describe("Slice creators", () => {

store.dispatch(undone());

expect(selectLastBook(store.getState())).toBe(book2);
expect(selectLastBook(store.getState())).toBe(book1);

store.dispatch(jumped(-1));
store.dispatch(jumped(1));

expect(selectLastBook(store.getState())).toStrictEqual(book2);

Expand Down Expand Up @@ -283,8 +283,8 @@ describe("Slice creators", () => {

expect(selectLastBook(store.getState())).toBeUndefined();
});
it("works without patches", () => {
const bookAdapter = createNoPatchHistoryAdapter<Array<Book>>();
it("works with patches", () => {
const bookAdapter = createPatchHistoryAdapter<Array<Book>>();
const bookSlice = createAppSlice({
name: "book",
initialState: bookAdapter.getInitialState([]),
Expand Down
Loading

0 comments on commit f258158

Please sign in to comment.