Skip to content
Myr

Added test reproducing #356

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Michel Weststrate · committed by Michel Weststrate · parent 47529d3 · Browse files · 1 file+15 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+15 added−0 removed

  • tests:+15 added−0 removed

1 file+15 added−0 removed

modified:__tests__/produce.ts+15 added
399 unmodified lines
400 // we can force the return type of the reducer by passing the generic argument401 const newState3 = produce(reducer, state)<State>()402 assert(newState3, _ as State)403})404405it("works with generic array", () => {406 const append = <T>(queue: T[], item: T) =>407 // T[] is needed here v. Too bad.408 produce(queue, (queueDraft: T[]) => {409 queueDraft.push(item)410 })411412 const queueBefore = [1, 2, 3]413414 const queueAfter = append(queueBefore, 4)415416 expect(queueAfter).toEqual([1, 2, 3, 4])417 expect(queueBefore).toEqual([1, 2, 3])418})