|
1 | 1 | import React, { Component } from 'react'; |
2 | 2 | import Form from '../src/Form'; |
3 | | -import { bindState, updated, buildHandlersCache } from '../src/utils'; |
| 3 | +import { bindState, buildHandlersCache } from '../src/utils'; |
4 | 4 | import { shallow } from 'enzyme'; |
5 | 5 | import expect from 'expect'; |
6 | 6 |
|
7 | | -describe('updated', function() { |
8 | | - it('carefully sets deeply nested item: deeply nested array', function() { |
9 | | - const obj = { foo: { bar: { baz: [1, 2, 3] } }, bak: { big: 1 } }; |
10 | | - const upd = updated(obj, 'foo.bar.baz.1', 4); |
11 | | - |
12 | | - expect(obj === upd).toBe(false, 'obj should not be updated in place'); |
13 | | - expect(obj.foo === upd.foo).toBe(false, 'obj.foo should not be updated in place'); |
14 | | - expect(obj.foo.bar === upd.foo.bar).toBe(false, 'obj.foo.bar should not be updated in place'); |
15 | | - expect(obj.foo.bar.baz === upd.foo.bar.baz).toBe(false, 'obj.foo.bar.baz should not be updated in place'); |
16 | | - expect(obj.bak === upd.bak).toBe(true, 'obj.bak should not be cloned'); |
17 | | - expect(upd.foo.bar.baz).toMatch([1, 4, 3], 'value under desired name should be updated'); |
18 | | - }); |
19 | | - |
20 | | - it('carefully sets deeply nested item: deeply nested object', function() { |
21 | | - const obj = { foo: { bar: [{ baz: 'baz1' }, { baz: 'baz2' }] }, bak: { big: 1 } }; |
22 | | - const upd = updated(obj, 'foo.bar.1.baz', 'baz3'); |
23 | | - |
24 | | - expect(obj === upd).toBe(false, 'obj should not be updated in place'); |
25 | | - expect(obj.foo === upd.foo).toBe(false, 'obj.foo should not be updated in place'); |
26 | | - expect(obj.foo.bar === upd.foo.bar).toBe(false, 'obj.foo.bar should not be updated in place'); |
27 | | - expect(obj.foo.bar[0] === upd.foo.bar[0]).toBe(true, 'obj.foo.bar items should not be cloned'); |
28 | | - expect(obj.bak === upd.bak).toBe(true, 'obj.bak should not be cloned'); |
29 | | - expect(upd.foo.bar[1]).toMatch({ baz: 'baz3' }, 'value under desired name should be updated'); |
30 | | - }); |
31 | | - |
32 | | - it('carefully sets deeply nested item, path collections are not defined', function() { |
33 | | - const obj = { bak: { big: 1 } }; |
34 | | - const upd = updated(obj, 'foo.bar.baz.1', 4); |
35 | | - |
36 | | - expect(obj.bak === upd.bak).toBe(true, 'obj.bak should not be cloned'); |
37 | | - expect(upd.foo.bar.baz).toMatch([undefined, 4], 'value under desired name should be updated'); |
38 | | - }); |
39 | | -}); |
40 | | - |
41 | 7 | describe('bindState', function() { |
42 | 8 | class Page extends Component { |
43 | 9 | render() { |
|
0 commit comments