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
Provenance
- Commit
9081634- Tree
19ba648- Author
Michel Weststrate <mweststrate@fb.com>- Committer
Michel Weststrate <mweststrate@fb.com>- Parent
fdf4be6
6 files changed+27 added−4 removed
modified:__tests__/base.js+14 added
587 unmodified lines588 produce(map, d => {589 expect(d instanceof Map).toBeTruthy()590 })591 })592+593+ 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 })607 608 describe("set drafts", () => {609 it("supports iteration", () => {1379 unmodified linesmodified:__tests__/draft.ts+6 added-1 removed
1 import {assert, _} from "spec.ts"2-import produce, {Draft, Draft, castDraft, original} from "../src/index"2+import produce, {Draft, castDraft, original} from "../src/index"3 4 // For checking if a type is assignable to its draft type (and vice versa)5 const toDraft: <T>(value: T) => Draft<T> = x => x as any6 const fromDraft: <T>(draft: Draft<T>) => T = x => x as any317 unmodified lines324 const nextState = produce(baseState, draftState => {325 original(draftState.users) === baseState.users326 })327 })328+329+test("asDraft preserves a value", () => {330+ const x = {}331+ expect(castDraft(x)).toBe(x)332+})modified:__tests__/immutable.ts+5 added
108 unmodified linesExpand all109110111112113114115116117108 unmodified linesExpand all immutable, _ as {readonly todos: ReadonlyArray<{readonly done: boolean}>} )})
test("castImmutable preserves a value", () => { const x = {} expect(castImmutable(x)).toBe(x)})modified:src/extends.ts+1 added
1234519 unmodified lines/* istanbul ignore next */var extendStatics = function(d: any, b: any): any { extendStatics = Object.setPrototypeOf || ({__proto__: []} instanceof Array &&19 unmodified linesmodified:src/map.ts-3 removed
91 unmodified lines92 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 }98 99 p.forEach = function(85 unmodified linesmodified:package.json+1 added
13 unmodified lines14 "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