Skip to content

Commit

Permalink
improve string formating
Browse files Browse the repository at this point in the history
  • Loading branch information
grosto committed May 2, 2021
1 parent 2e94112 commit 0e0aa43
Show file tree
Hide file tree
Showing 14 changed files with 381 additions and 308 deletions.
11 changes: 7 additions & 4 deletions packages/jest-deep-diff/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ There is support for plugins. I have made ReactElement and AsymmetricMatcher Plu
- [x] Array
- [x] Object
- [x] Circular
- [ ] Map
- [x] Map (Does not checks equality of complex value keys)
- [ ] Set
- [ ] DOM Node
- [x] Asymmetric Any
- [ ] Asymmetric Object
- [ ] React
- [x] Asymmetric Any
- [x] Asymmetric Object

I am quite happy with this module. It's clear to me what it does. It recursively marks values as Inserted, Updated, Deleted, Equal or TypeUnequal and returns an object which represents the differences between 2 values.

Expand All @@ -51,9 +51,12 @@ Note: Diff will also traverse and mark all the children of complex values
- [x] Circular
- [ ] Date
- [ ] RegExp
- [ ] Map
- [x] Map
- [ ] Set
- [ ] DOM Node
- [ ] React
- [x] Asymmetric Any
- [x] Asymmetric Object

`format` has two parts, `diffFormat`(desperately needs a name) and `print`. The first one returns an array of `Line` objects and the second serializes this array based on options.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,67 +266,31 @@ Object {
}
`;

exports[`Objects correctly propagates "updated" to parent 1`] = `
exports[`Objects marks updated field 1`] = `
Object {
"a": Object {
"a": 1,
"b": Object {
"c": Object {
"d": 2,
},
},
"b": 2,
},
"b": Object {
"a": 1,
"b": Object {
"c": Object {
"d": 1,
},
},
"b": 3,
},
"childDiffs": Array [
Object {
"a": 1,
"b": 1,
"kind": 0,
"kind": "EQUAL",
"path": "a",
},
Object {
"a": Object {
"c": Object {
"d": 2,
},
},
"b": Object {
"c": Object {
"d": 1,
},
},
"childDiffs": Array [
Object {
"a": Object {
"d": 2,
},
"b": Object {
"d": 1,
},
"childDiffs": Array [
Object {
"a": 2,
"b": 1,
"kind": 1,
"path": "d",
},
],
"kind": 1,
"path": "c",
},
],
"kind": 1,
"a": 2,
"b": 3,
"kind": "UPDATED",
"path": "b",
},
],
"kind": 1,
"kind": "UPDATED",
"path": undefined,
}
`;
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,6 @@ exports[`collapses big diffs to patch format 1`] = `
<d> }</>
`;
exports[`color of text (expanded) 1`] = `
<g>- Expected</>
<r>+ Received</>
<d> Object {</>
<d> "searching": "",</>
<g>- "sorting": Object {</>
<g> "descending": false,</>
<g> "fieldKey": "what",</>
<g> },</>
<r>+ "sorting": Array [</>
<r> Object {</>
<r> "descending": false,</>
<r> "fieldKey": "what",</>
<r> },</>
<r> ],</>
<d> }</>
`;
exports[`context number of lines: -1 (5 default) 1`] = `
<g>- Expected</>
<r>+ Received</>
Expand Down
Loading

0 comments on commit 0e0aa43

Please sign in to comment.