Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | 2x 2x | import type {TestCase} from './types'; const testCases: TestCase[] = [ { comment: 'Can set root document', doc: null, patch: [{op: 'add', path: '', value: {a: 'b'}}], expected: {a: 'b'}, }, { comment: 'Can set empty object key to string', doc: {}, patch: [{op: 'add', path: '/a', value: 'b'}], expected: {a: 'b'}, }, { comment: 'Can set empty object key to object', doc: {}, patch: [{op: 'add', path: '/aga', value: {foo: 'bar'}}], expected: {aga: {foo: 'bar'}}, }, { comment: 'Can update existing key', doc: {z: 1}, patch: [{op: 'add', path: '/z', value: 2}], expected: {z: 2}, }, { comment: 'Can insert into first level empty array using index "0"', doc: [], patch: [{op: 'add', path: '/0', value: null}], expected: [null], }, { comment: 'Can insert into first level empty array using index "-"', doc: [], patch: [{op: 'add', path: '/-', value: null}], expected: [null], }, { comment: 'Throws error when inserting into empty first level array at index "1"', doc: [], patch: [{op: 'add', path: '/1', value: null}], error: 'INVALID_INDEX', }, { comment: 'Can insert into second level empty array using index "0"', doc: {'1': []}, patch: [{op: 'add', path: '/1/0', value: null}], expected: {'1': [null]}, }, { comment: 'Can insert into first level empty array using index "-"', doc: {'1': []}, patch: [{op: 'add', path: '/1/-', value: null}], expected: {'1': [null]}, }, { comment: 'Throws error when inserting into empty first level array at index "1"', doc: {'1': []}, patch: [{op: 'add', path: '/1/1', value: null}], error: 'INVALID_INDEX', }, { comment: 'Can execute multiple updates in a row', doc: { id: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', name: 'Henry Ho', tags: ['News', 'Sports'], address: { street: 'Google Way 15', zip: '101', }, }, patch: [ {op: 'add', path: '/address/street', value: 'Facebook Boulevard 53'}, {op: 'add', path: '/surname', value: 'Ho'}, {op: 'add', path: '/name', value: 'Henry'}, {op: 'add', path: '/tags/-', value: 'Tech'}, {op: 'add', path: '/tags/3', value: 'Programming'}, {op: 'add', path: '/tags/0', value: 'TDD'}, {op: 'add', path: '/tags/1', value: 'Lady Gaga'}, {op: 'add', path: '/address/name', value: 'H. Ho'}, ], expected: { id: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', name: 'Henry', surname: 'Ho', tags: ['TDD', 'Lady Gaga', 'News', 'Sports', 'Tech', 'Programming'], address: { name: 'H. Ho', street: 'Facebook Boulevard 53', zip: '101', }, }, skipInJsonOt: true, }, ]; export default testCases; |