Skip to content

Commit

Permalink
test: add duplicates tracking test, this may need revisiting
Browse files Browse the repository at this point in the history
  • Loading branch information
dxinteractive committed Mar 17, 2022
1 parent 10a5a4d commit 109e799
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion packages/dendriform-immer-patch-optimiser/test/optimise.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ describe(`change deep arrays`, () => {
);
});

describe(`sort with mutiple identical values`, () => {
describe(`dont optimise with primitive values`, () => {
runTest(
['b','a','c','a','c','b','a'],
d => {
Expand Down Expand Up @@ -480,6 +480,27 @@ describe(`sort with mutiple identical values`, () => {
);
});

describe(`deal with multiple identical values`, () => {
runTest(
[A,A,B,A],
d => {
d.shift();
},
[A,B,A],
{
vanilla: [
{op: 'replace', path: [1], value: B},
{op: 'replace', path: [2], value: A},
{op: 'replace', path: ['length'], value: 3}
],
optimised: [
{op: 'move', from: [2], path: [1]},
{op: 'replace', path: ['length'], value: 3}
]
}
);
});

describe(`filter with returned arrays`, () => {
runTest(
[A,B,C,D,E],
Expand Down

0 comments on commit 109e799

Please sign in to comment.