Skip to content
Myr

Fixed some test issues

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 fdf4be6 · Browse files · 6 files+27 added−4 removed
This commit

State

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

Diff stats

6 files+27 added−4 removed

  • tests:+25 added−1 removed
  • other:+2 added−3 removed

6 files+27 added−4 removed

modified:__tests__/base.js+14 added
587 unmodified lines
588 produce(map, d => {589 expect(d instanceof Map).toBeTruthy()590 })591 })592593 it("handles clear correctly", () => {594 const map = new Map([595 ["a", 1],596 ["c", 3]597 ])598 const next = produce(map, draft => {599 draft.delete("a")600 draft.set("b", 2)601 draft.set("c", 4)602 draft.clear()603 })604 expect(next).toEqual(new Map())605 })606 })607608 describe("set drafts", () => {609 it("supports iteration", () => {
1379 unmodified lines
modified:__tests__/draft.ts+6 added-1 removed
1import {assert, _} from "spec.ts"2import produce, {Draft, Draft, castDraft, original} from "../src/index"2import produce, {Draft, castDraft, original} from "../src/index"34// For checking if a type is assignable to its draft type (and vice versa)5const toDraft: <T>(value: T) => Draft<T> = x => x as any6const fromDraft: <T>(draft: Draft<T>) => T = x => x as any
317 unmodified lines
324 const nextState = produce(baseState, draftState => {325 original(draftState.users) === baseState.users326 })327})328329test("asDraft preserves a value", () => {330 const x = {}331 expect(castDraft(x)).toBe(x)332})
modified:__tests__/immutable.ts+5 added
modified:src/extends.ts+1 added
modified:src/map.ts-3 removed
91 unmodified lines
92 assertUnrevoked(state)93 prepareCopy(state)94 state.scope.immer.markChanged(state)95 state.assigned = new Map()96 for (const key of latest(state).keys()) {97 state.assigned.set(key, false)98 }96 return state.copy!.clear()97 }9899 p.forEach = function(
85 unmodified lines
modified:package.json+1 added
13 unmodified lines
14 "test": "jest",15 "test:perf": "NODE_ENV=production yarn-or-npm build && cd __performance_tests__ && babel-node add-data.js && babel-node todo.js && babel-node incremental.js",16 "test:flow": "yarn-or-npm flow check __tests__/flow",17 "watch": "jest --watch",18 "coverage": "jest --coverage",19 "coveralls": "jest --coverage && cat ./coverage/lcov.info | ./node_modules/.bin/coveralls && rm -rf ./coverage",20 "build": "rimraf dist/ && yarn-or-npm bili && yarn-or-npm typed",21 "typed": "cpx 'src/immer.js.flow' dist -v",22 "publish-docs": "cd website && GIT_USER=mweststrate USE_SSH=true yarn run publish-gh-pages",
83 unmodified lines