immutable 4.0.0-rc.12 → 4.0.0-rc.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "immutable",
3
- "version": "4.0.0-rc.12",
3
+ "version": "4.0.0-rc.14",
4
4
  "description": "Immutable Data Collections",
5
5
  "license": "MIT",
6
- "homepage": "https://facebook.github.com/immutable-js",
6
+ "homepage": "https://immutable-js.com",
7
7
  "author": {
8
8
  "name": "Lee Byron",
9
9
  "url": "https://github.com/leebyron"
10
10
  },
11
11
  "repository": {
12
12
  "type": "git",
13
- "url": "git://github.com/facebook/immutable-js.git"
13
+ "url": "git://github.com/immutable-js/immutable-js.git"
14
14
  },
15
15
  "bugs": {
16
- "url": "https://github.com/facebook/immutable-js/issues"
16
+ "url": "https://github.com/immutable-js/immutable-js/issues"
17
17
  },
18
18
  "main": "dist/immutable.js",
19
19
  "module": "dist/immutable.es.js",
@@ -21,95 +21,8 @@
21
21
  "typescript": {
22
22
  "definition": "dist/immutable.d.ts"
23
23
  },
24
- "scripts": {
25
- "build": "run-s build:*",
26
- "build:dist": "run-s clean:dist bundle:dist bundle:es copy:dist stats:dist",
27
- "build:pages": "gulp --gulpfile ./resources/gulpfile.js default",
28
- "stats:dist": "node ./resources/dist-stats.js",
29
- "clean:dist": "rimraf dist",
30
- "bundle:dist": "rollup -c ./resources/rollup-config.js",
31
- "bundle:es": "rollup -c ./resources/rollup-config-es.js",
32
- "copy:dist": "node ./resources/copy-dist-typedefs.js",
33
- "lint": "run-s lint:*",
34
- "lint:ts": "tslint \"__tests__/**/*.ts\"",
35
- "lint:js": "eslint \"{__tests__,src,pages/src,pages/lib}/**/*.js\"",
36
- "format": "prettier --single-quote --trailing-comma=es5 --write \"{__tests__,src,pages/src,pages/lib,perf,resources}/**/*{\\.js,\\.ts}\"",
37
- "testonly": "./resources/jest",
38
- "test": "run-s format build lint testonly test:types:*",
39
- "test:travis": "npm run test && ./resources/check-changes",
40
- "test:types:ts": "tsc ./type-definitions/Immutable.d.ts --lib es2015 && dtslint type-definitions/ts-tests",
41
- "test:types:flow": "flow check type-definitions/tests --include-warnings",
42
- "perf": "node ./resources/bench.js",
43
- "start": "gulp --gulpfile ./resources/gulpfile.js dev",
44
- "deploy": "./resources/deploy-ghpages.sh",
45
- "gitpublish": "./resources/gitpublish.sh"
46
- },
47
- "jest": {
48
- "moduleFileExtensions": [
49
- "js",
50
- "ts"
51
- ],
52
- "transform": {
53
- "^.+\\.ts$": "<rootDir>/resources/jestPreprocessor.js"
54
- },
55
- "testRegex": "/__tests__/.*\\.(ts|js)$",
56
- "unmockedModulePathPatterns": [
57
- "./node_modules/react"
58
- ]
59
- },
60
- "devDependencies": {
61
- "benchmark": "2.1.4",
62
- "browser-sync": "^2.26.3",
63
- "browserify": "16.2.2",
64
- "colors": "1.2.5",
65
- "del": "3.0.0",
66
- "dtslint": "0.1.2",
67
- "eslint": "4.19.1",
68
- "eslint-config-airbnb": "16.1.0",
69
- "eslint-config-prettier": "2.9.0",
70
- "eslint-plugin-import": "2.12.0",
71
- "eslint-plugin-jsx-a11y": "6.0.3",
72
- "eslint-plugin-prettier": "2.6.2",
73
- "eslint-plugin-react": "7.8.2",
74
- "flow-bin": "0.85.0",
75
- "gulp": "3.9.1",
76
- "gulp-concat": "2.6.1",
77
- "gulp-filter": "5.1.0",
78
- "gulp-header": "2.0.5",
79
- "gulp-less": "3.5.0",
80
- "gulp-size": "3.0.0",
81
- "gulp-sourcemaps": "2.6.4",
82
- "gulp-uglify": "2.1.0",
83
- "gulp-util": "3.0.8",
84
- "jasmine-check": "0.1.5",
85
- "jest": "23.6.0",
86
- "marked": "0.3.19",
87
- "microtime": "2.1.8",
88
- "mkdirp": "0.5.1",
89
- "npm-run-all": "4.1.3",
90
- "prettier": "1.14.2",
91
- "react": "^0.12.0",
92
- "react-router": "^0.11.2",
93
- "react-tools": "0.13.3",
94
- "rimraf": "2.6.2",
95
- "rollup": "0.59.1",
96
- "rollup-plugin-buble": "0.19.2",
97
- "rollup-plugin-commonjs": "9.1.3",
98
- "rollup-plugin-json": "3.0.0",
99
- "rollup-plugin-strip-banner": "0.2.0",
100
- "run-sequence": "2.2.1",
101
- "through2": "2.0.3",
102
- "transducers-js": "^0.4.174",
103
- "tslint": "5.7.0",
104
- "typescript": "3.0.3",
105
- "uglify-js": "2.8.11",
106
- "uglify-save-license": "0.4.1",
107
- "vinyl-buffer": "1.0.1",
108
- "vinyl-source-stream": "2.0.0"
109
- },
110
24
  "files": [
111
25
  "dist",
112
- "contrib",
113
26
  "README.md",
114
27
  "LICENSE"
115
28
  ],
@@ -124,6 +37,5 @@
124
37
  "stateless",
125
38
  "sequence",
126
39
  "iteration"
127
- ],
128
- "dependencies": {}
129
- }
40
+ ]
41
+ }
@@ -1,43 +0,0 @@
1
- # DEPRECATED
2
-
3
- The Cursor API is deprecated and will be removed in a future major release.
4
-
5
- It is strongly suggested that you use the excellent `immutable-cursor` module
6
- which has an extremely similar API but is much higher quality.
7
-
8
- https://github.com/redbadger/immutable-cursor
9
-
10
-
11
- Cursors
12
- -------
13
-
14
- Cursors allow you to hold a reference to a path in a nested immutable data
15
- structure, allowing you to pass smaller sections of a larger nested
16
- collection to portions of your application while maintaining a central point
17
- aware of changes to the entire data structure: an `onChange` function which is
18
- called whenever a cursor or sub-cursor calls `update`.
19
-
20
- This is particularly useful when used in conjunction with component-based UI
21
- libraries like [React](https://facebook.github.io/react/) or to simulate
22
- "state" throughout an application while maintaining a single flow of logic.
23
-
24
-
25
- ```javascript
26
- var Immutable = require('immutable');
27
- var Cursor = require('immutable/contrib/cursor');
28
-
29
- var data = Immutable.fromJS({ a: { b: { c: 1 } } });
30
- var cursor = Cursor.from(data, ['a', 'b'], newData => {
31
- data = newData;
32
- });
33
-
34
- // ... elsewhere ...
35
-
36
- cursor.get('c'); // 1
37
- cursor = cursor.update('c', x => x + 1);
38
- cursor.get('c'); // 2
39
-
40
- // ... back to data ...
41
-
42
- data.getIn(['a', 'b', 'c']); // 2
43
- ```
@@ -1,395 +0,0 @@
1
- /**
2
- * Copyright (c) 2014-present, Facebook, Inc.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
-
8
- ///<reference path='../../../resources/jest.d.ts'/>
9
-
10
- import * as Immutable from '../../../';
11
- import * as Cursor from '../';
12
-
13
- describe('Cursor', () => {
14
-
15
- beforeEach(function () {
16
- jasmine.addMatchers({
17
- toValueEqual: function(actual, expected) {
18
- var passed = Immutable.is(actual, expected);
19
- return {
20
- pass: passed,
21
- message: 'Expected ' + actual + (passed ? '' : ' not') + ' to equal ' + expected
22
- };
23
- }
24
- });
25
- });
26
-
27
- var json = { a: { b: { c: 1 } } };
28
-
29
- it('gets from its path', () => {
30
- var data = Immutable.fromJS(json);
31
- var cursor = Cursor.from(data);
32
-
33
- expect(cursor.deref()).toBe(data);
34
-
35
- var deepCursor = cursor.cursor(['a', 'b']);
36
- expect(deepCursor.deref().toJS()).toEqual(json.a.b);
37
- expect(deepCursor.deref()).toBe(data.getIn(['a', 'b']));
38
- expect(deepCursor.get('c')).toBe(1);
39
-
40
- var leafCursor = deepCursor.cursor('c');
41
- expect(leafCursor.deref()).toBe(1);
42
-
43
- var missCursor = leafCursor.cursor('d');
44
- expect(missCursor.deref()).toBe(undefined);
45
- });
46
-
47
- it('gets return new cursors', () => {
48
- var data = Immutable.fromJS(json);
49
- var cursor = Cursor.from(data);
50
- var deepCursor = cursor.getIn(['a', 'b']);
51
- expect(deepCursor.deref()).toBe(data.getIn(['a', 'b']));
52
- });
53
-
54
- it('gets return new cursors using List', () => {
55
- var data = Immutable.fromJS(json);
56
- var cursor = Cursor.from(data);
57
- var deepCursor = cursor.getIn(Immutable.fromJS(['a', 'b']));
58
- expect(deepCursor.deref()).toBe(data.getIn(Immutable.fromJS(['a', 'b'])));
59
- });
60
-
61
- it('cursor return new cursors of correct type', () => {
62
- var data = Immutable.fromJS({ a: [1, 2, 3] });
63
- var cursor = Cursor.from(data);
64
- var deepCursor = <any>cursor.cursor('a');
65
- expect(deepCursor.findIndex).toBeDefined();
66
- });
67
-
68
- it('can be treated as a value', () => {
69
- var data = Immutable.fromJS(json);
70
- var cursor = Cursor.from(data, ['a', 'b']);
71
- expect(cursor.toJS()).toEqual(json.a.b);
72
- expect(cursor).toValueEqual(data.getIn(['a', 'b']));
73
- expect(cursor.size).toBe(1);
74
- expect(cursor.get('c')).toBe(1);
75
- });
76
-
77
- it('can be value compared to a primitive', () => {
78
- var data = Immutable.Map({ a: 'A' });
79
- var aCursor = Cursor.from(data, 'a');
80
- expect(aCursor.size).toBe(undefined);
81
- expect(aCursor.deref()).toBe('A');
82
- expect(Immutable.is(aCursor, 'A')).toBe(true);
83
- });
84
-
85
- it('updates at its path', () => {
86
- var onChange = jest.genMockFunction();
87
-
88
- var data = Immutable.fromJS(json);
89
- var aCursor = Cursor.from(data, 'a', onChange);
90
-
91
- var deepCursor = aCursor.cursor(['b', 'c']);
92
- expect(deepCursor.deref()).toBe(1);
93
-
94
- // cursor edits return new cursors:
95
- var newDeepCursor = deepCursor.update(x => x + 1);
96
- expect(newDeepCursor.deref()).toBe(2);
97
- var call1 = onChange.mock.calls[0];
98
- expect(call1[0]).toValueEqual(Immutable.fromJS({a:{b:{c:2}}}));
99
- expect(call1[1]).toBe(data);
100
- expect(call1[2]).toEqual(['a', 'b', 'c']);
101
-
102
- var newestDeepCursor = newDeepCursor.update(x => x + 1);
103
- expect(newestDeepCursor.deref()).toBe(3);
104
- var call2 = onChange.mock.calls[1];
105
- expect(call2[0]).toValueEqual(Immutable.fromJS({a:{b:{c:3}}}));
106
- expect(call2[1]).toValueEqual(Immutable.fromJS({a:{b:{c:2}}}));
107
- expect(call2[2]).toEqual(['a', 'b', 'c']);
108
-
109
- // meanwhile, data is still immutable:
110
- expect(data.toJS()).toEqual(json);
111
-
112
- // as is the original cursor.
113
- expect(deepCursor.deref()).toBe(1);
114
- var otherNewDeepCursor = deepCursor.update(x => x + 10);
115
- expect(otherNewDeepCursor.deref()).toBe(11);
116
- var call3 = onChange.mock.calls[2];
117
- expect(call3[0]).toValueEqual(Immutable.fromJS({a:{b:{c:11}}}));
118
- expect(call3[1]).toBe(data);
119
- expect(call3[2]).toEqual(['a', 'b', 'c']);
120
-
121
- // and update has been called exactly thrice.
122
- expect(onChange.mock.calls.length).toBe(3);
123
- });
124
-
125
- it('updates with the return value of onChange', () => {
126
- var onChange = jest.genMockFunction();
127
-
128
- var data = Immutable.fromJS(json);
129
- var deepCursor = Cursor.from(data, ['a', 'b', 'c'], onChange);
130
-
131
- onChange.mockReturnValueOnce(undefined);
132
- // onChange returning undefined has no effect
133
- var newCursor = deepCursor.update(x => x + 1);
134
- expect(newCursor.deref()).toBe(2);
135
- var call1 = onChange.mock.calls[0];
136
- expect(call1[0]).toValueEqual(Immutable.fromJS({a:{b:{c:2}}}));
137
- expect(call1[1]).toBe(data);
138
- expect(call1[2]).toEqual(['a', 'b', 'c']);
139
-
140
- onChange.mockReturnValueOnce(Immutable.fromJS({a:{b:{c:11}}}));
141
- // onChange returning something else has an effect
142
- newCursor = newCursor.update(x => 999);
143
- expect(newCursor.deref()).toBe(11);
144
- var call2 = onChange.mock.calls[1];
145
- expect(call2[0]).toValueEqual(Immutable.fromJS({a:{b:{c:999}}}));
146
- expect(call2[1]).toValueEqual(Immutable.fromJS({a:{b:{c:2}}}));
147
- expect(call2[2]).toEqual(['a', 'b', 'c']);
148
-
149
- // and update has been called exactly twice
150
- expect(onChange.mock.calls.length).toBe(2);
151
- });
152
-
153
- it('has map API for update shorthand', () => {
154
- var onChange = jest.genMockFunction();
155
-
156
- var data = Immutable.fromJS(json);
157
- var aCursor = Cursor.from(data, 'a', onChange);
158
- var bCursor = aCursor.cursor('b');
159
- var cCursor = bCursor.cursor('c');
160
-
161
- expect(bCursor.set('c', 10).deref()).toValueEqual(
162
- Immutable.fromJS({ c: 10 })
163
- );
164
-
165
- var call1 = onChange.mock.calls[0];
166
- expect(call1[0]).toValueEqual(Immutable.fromJS({a:{b:{c:10}}}));
167
- expect(call1[1]).toBe(data);
168
- expect(call1[2]).toEqual(['a', 'b', 'c']);
169
- });
170
-
171
- it('creates maps as necessary', () => {
172
- var data = Immutable.Map();
173
- var cursor = Cursor.from(data, ['a', 'b', 'c']);
174
- expect(cursor.deref()).toBe(undefined);
175
- cursor = cursor.set('d', 3);
176
- expect(cursor.deref()).toValueEqual(Immutable.Map({d: 3}));
177
- });
178
-
179
- it('can set undefined', () => {
180
- var data = Immutable.Map();
181
- var cursor = Cursor.from(data, ['a', 'b', 'c']);
182
- expect(cursor.deref()).toBe(undefined);
183
- cursor = cursor.set('d', undefined);
184
- expect(cursor.toJS()).toEqual({d: undefined});
185
- });
186
-
187
- it('has the sequence API', () => {
188
- var data = Immutable.Map({a: 1, b: 2, c: 3});
189
- var cursor = Cursor.from(data);
190
- expect(cursor.map((x: number) => x * x)).toValueEqual(Immutable.Map({a: 1, b: 4, c: 9}));
191
- });
192
-
193
- it('can push values on a List', () => {
194
- var onChange = jest.genMockFunction();
195
- var data = Immutable.fromJS({a: {b: [0, 1, 2]}});
196
- var cursor = Cursor.from(data, ['a', 'b'], onChange);
197
-
198
- expect(cursor.push(3,4)).toValueEqual(Immutable.List([0, 1, 2, 3, 4]));
199
-
200
- var call = onChange.mock.calls[0];
201
- expect(call[0]).toValueEqual(Immutable.fromJS({a: {b: [0, 1, 2, 3, 4]}}));
202
- expect(call[1]).toBe(data);
203
- expect(call[2]).toEqual(['a', 'b']);
204
- });
205
-
206
- it('can pop values of a List', () => {
207
- var onChange = jest.genMockFunction();
208
- var data = Immutable.fromJS({a: {b: [0, 1, 2]}});
209
- var cursor = Cursor.from(data, ['a', 'b'], onChange);
210
-
211
- expect(cursor.pop()).toValueEqual(Immutable.List([0, 1]));
212
-
213
- var call = onChange.mock.calls[0];
214
- expect(call[0]).toValueEqual(Immutable.fromJS({a: {b: [0, 1]}}));
215
- expect(call[1]).toBe(data);
216
- expect(call[2]).toEqual(['a', 'b']);
217
- });
218
-
219
- it('can unshift values on a List', () => {
220
- var onChange = jest.genMockFunction();
221
- var data = Immutable.fromJS({a: {b: [0, 1, 2]}});
222
- var cursor = Cursor.from(data, ['a', 'b'], onChange);
223
-
224
- expect(cursor.unshift(-2, -1)).toValueEqual(Immutable.List([-2, -1, 0, 1, 2]));
225
-
226
- var call = onChange.mock.calls[0];
227
- expect(call[0]).toValueEqual(Immutable.fromJS({a: {b: [-2, -1, 0, 1, 2]}}));
228
- expect(call[1]).toBe(data);
229
- expect(call[2]).toEqual(['a', 'b']);
230
- });
231
-
232
- it('can shift values of a List', () => {
233
- var onChange = jest.genMockFunction();
234
- var data = Immutable.fromJS({a: {b: [0, 1, 2]}});
235
- var cursor = Cursor.from(data, ['a', 'b'], onChange);
236
-
237
- expect(cursor.shift()).toValueEqual(Immutable.List([1, 2]));
238
-
239
- var call = onChange.mock.calls[0];
240
- expect(call[0]).toValueEqual(Immutable.fromJS({a: {b: [1, 2]}}));
241
- expect(call[1]).toBe(data);
242
- expect(call[2]).toEqual(['a', 'b']);
243
- });
244
-
245
-
246
- it('returns wrapped values for sequence API', () => {
247
- var data = Immutable.fromJS({a: {v: 1}, b: {v: 2}, c: {v: 3}});
248
- var onChange = jest.genMockFunction();
249
- var cursor = Cursor.from(data, onChange);
250
-
251
- var found = cursor.find(map => map.get('v') === 2);
252
- expect(typeof found.deref).toBe('function'); // is a cursor!
253
- found = found.set('v', 20);
254
-
255
- var call = onChange.mock.calls[0];
256
- expect(call[0]).toValueEqual(Immutable.fromJS({a: {v: 1}, b: {v: 20}, c: {v: 3}}));
257
- expect(call[1]).toBe(data);
258
- expect(call[2]).toEqual(['b', 'v']);
259
- });
260
-
261
- it('returns wrapped values for iteration API', () => {
262
- var jsData = [{val: 0}, {val: 1}, {val: 2}];
263
- var data = Immutable.fromJS(jsData);
264
- var cursor = Cursor.from(data);
265
- cursor.forEach(function (c, i) {
266
- expect(typeof c.deref).toBe('function'); // is a cursor!
267
- expect(c.get('val')).toBe(i);
268
- });
269
- });
270
-
271
- it('can map over values to get subcursors', () => {
272
- var data = Immutable.fromJS({a: {v: 1}, b: {v: 2}, c: {v: 3}});
273
- var cursor = Cursor.from(data);
274
-
275
- var mapped = cursor.map(val => {
276
- expect(typeof val.deref).toBe('function'); // mapped values are cursors.
277
- return val;
278
- }).toMap();
279
- // Mapped is not a cursor, but it is a sequence of cursors.
280
- expect(typeof (<any>mapped).deref).not.toBe('function');
281
- expect(typeof (<any>mapped.get('a')).deref).toBe('function');
282
-
283
- // Same for indexed cursors
284
- var data2 = Immutable.fromJS({x: [{v: 1}, {v: 2}, {v: 3}]});
285
- var cursor2 = Cursor.from(data2);
286
-
287
- var mapped2 = cursor2.get('x').map(val => {
288
- expect(typeof val.deref).toBe('function'); // mapped values are cursors.
289
- return val;
290
- }).toList();
291
- // Mapped is not a cursor, but it is a sequence of cursors.
292
- expect(typeof mapped2.deref).not.toBe('function');
293
- expect(typeof mapped2.get(0).deref).toBe('function');
294
- });
295
-
296
- it('can have mutations apply with a single callback', () => {
297
- var onChange = jest.genMockFunction();
298
- var data = Immutable.fromJS({'a': 1});
299
-
300
- var c1 = Cursor.from(data, onChange);
301
- var c2 = c1.withMutations(m => m.set('b', 2).set('c', 3).set('d', 4));
302
-
303
- expect(c1.deref().toObject()).toEqual({'a': 1});
304
- expect(c2.deref().toObject()).toEqual({'a': 1, 'b': 2, 'c': 3, 'd': 4});
305
- expect(onChange.mock.calls.length).toBe(1);
306
- });
307
-
308
- it('can use withMutations on an unfulfilled cursor', () => {
309
- var onChange = jest.genMockFunction();
310
- var data = Immutable.fromJS({});
311
-
312
- var c1 = Cursor.from(data, ['a', 'b', 'c'], onChange);
313
- var c2 = c1.withMutations(m => m.set('x', 1).set('y', 2).set('z', 3));
314
-
315
- expect(c1.deref()).toEqual(undefined);
316
- expect(c2.deref()).toValueEqual(Immutable.fromJS(
317
- { x: 1, y: 2, z: 3 }
318
- ));
319
- expect(onChange.mock.calls.length).toBe(1);
320
- });
321
-
322
- it('maintains indexed sequences', () => {
323
- var data = Immutable.fromJS([]);
324
- var c = Cursor.from(data);
325
- expect(c.toJS()).toEqual([]);
326
- });
327
-
328
- it('properly acts as an iterable', () => {
329
- var data = Immutable.fromJS({key: {val: 1}});
330
- var c = Cursor.from(data).values();
331
- var c1 = c.next().value.get('val');
332
- expect(c1).toBe(1);
333
- });
334
-
335
- it('can update deeply', () => {
336
- var onChange = jest.genMockFunction();
337
- var data = Immutable.fromJS({a:{b:{c:1}}});
338
- var c = Cursor.from(data, ['a'], onChange);
339
- var c1 = c.updateIn(['b', 'c'], x => x * 10);
340
- expect(c1.getIn(['b', 'c'])).toBe(10);
341
-
342
- var call = onChange.mock.calls[0];
343
- expect(call[0]).toValueEqual(Immutable.fromJS({a:{b:{c:10}}}));
344
- expect(call[1]).toBe(data);
345
- expect(call[2]).toEqual(['a', 'b', 'c']);
346
- });
347
-
348
- it('can set deeply', () => {
349
- var onChange = jest.genMockFunction();
350
- var data = Immutable.fromJS({a:{b:{c:1}}});
351
- var c = Cursor.from(data, ['a'], onChange);
352
- var c1 = c.setIn(['b', 'c'], 10);
353
- expect(c1.getIn(['b', 'c'])).toBe(10);
354
-
355
- var call = onChange.mock.calls[0];
356
- expect(call[0]).toValueEqual(Immutable.fromJS({a:{b:{c:10}}}));
357
- expect(call[1]).toBe(data);
358
- expect(call[2]).toEqual(['a', 'b', 'c']);
359
- });
360
-
361
- it('can get Record value as a property', () => {
362
- var User = Immutable.Record({ name: 'John' });
363
- var users = Immutable.List.of(new User());
364
- var data = Immutable.Map({'users': users});
365
- var cursor = Cursor.from(data, ['users']);
366
- expect(cursor.first().name).toBe('John');
367
- });
368
-
369
- it('can set value of a cursor directly', () => {
370
- var onChange = jest.genMockFunction();
371
- var data = Immutable.fromJS({a:1});
372
- var c = Cursor.from(data, ['a'], onChange);
373
- var c1 = c.set(2);
374
- expect(c1.deref()).toBe(2);
375
-
376
- var call = onChange.mock.calls[0];
377
- expect(call[0]).toValueEqual(Immutable.fromJS({a:2}));
378
- expect(call[1]).toBe(data);
379
- expect(call[2]).toEqual(['a']);
380
- });
381
-
382
- it('can set value of a cursor to undefined directly', () => {
383
- var onChange = jest.genMockFunction();
384
- var data = Immutable.fromJS({a:1});
385
- var c = Cursor.from(data, ['a'], onChange);
386
- var c1 = c.set(undefined);
387
- expect(c1.deref()).toBe(undefined);
388
-
389
- var call = onChange.mock.calls[0];
390
- expect(call[0]).toValueEqual(Immutable.fromJS({a:undefined}));
391
- expect(call[1]).toBe(data);
392
- expect(call[2]).toEqual(['a']);
393
- });
394
-
395
- });